diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/line_2d.cpp | 3 | ||||
-rw-r--r-- | scene/2d/particles_2d.cpp | 7 | ||||
-rw-r--r-- | scene/2d/sprite.cpp | 2 | ||||
-rw-r--r-- | scene/2d/tile_map.cpp | 5 | ||||
-rw-r--r-- | scene/3d/particles.cpp | 7 | ||||
-rw-r--r-- | scene/3d/sprite_3d.cpp | 4 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 153 | ||||
-rw-r--r-- | scene/gui/tree.h | 22 | ||||
-rw-r--r-- | scene/resources/material.cpp | 12 | ||||
-rw-r--r-- | scene/resources/tile_set.cpp | 20 | ||||
-rw-r--r-- | scene/resources/tile_set.h | 4 |
11 files changed, 197 insertions, 42 deletions
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index 1a57d24342..5438557d0b 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -310,12 +310,15 @@ void Line2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR2_ARRAY, "points"), "set_points", "get_points"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "default_color"), "set_default_color", "get_default_color"); + ADD_GROUP("Fill", ""); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "gradient", PROPERTY_HINT_RESOURCE_TYPE, "Gradient"), "set_gradient", "get_gradient"); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "texture_mode", PROPERTY_HINT_ENUM, "None,Tile"), "set_texture_mode", "get_texture_mode"); + ADD_GROUP("Capping", ""); ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "joint_mode", PROPERTY_HINT_ENUM, "Sharp,Bevel,Round"), "set_joint_mode", "get_joint_mode"); ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "begin_cap_mode", PROPERTY_HINT_ENUM, "None,Box,Round"), "set_begin_cap_mode", "get_begin_cap_mode"); ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "end_cap_mode", PROPERTY_HINT_ENUM, "None,Box,Round"), "set_end_cap_mode", "get_end_cap_mode"); + ADD_GROUP("Border", ""); ADD_PROPERTY(PropertyInfo(Variant::REAL, "sharp_limit"), "set_sharp_limit", "get_sharp_limit"); ADD_PROPERTY(PropertyInfo(Variant::INT, "round_precision"), "set_round_precision", "get_round_precision"); diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index ba795d58f4..aa9258c7b4 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -354,19 +354,20 @@ void Particles2D::_bind_methods() { ClassDB::bind_method(D_METHOD("restart"), &Particles2D::restart); - ADD_GROUP("Parameters", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emitting"), "set_emitting", "is_emitting"); ADD_PROPERTY(PropertyInfo(Variant::INT, "amount", PROPERTY_HINT_RANGE, "1,100000,1"), "set_amount", "get_amount"); + ADD_GROUP("Time", ""); ADD_PROPERTY(PropertyInfo(Variant::REAL, "lifetime", PROPERTY_HINT_RANGE, "0.01,600.0,0.01"), "set_lifetime", "get_lifetime"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "one_shot"), "set_one_shot", "get_one_shot"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "preprocess", PROPERTY_HINT_RANGE, "0.00,600.0,0.01"), "set_pre_process_time", "get_pre_process_time"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "speed_scale", PROPERTY_HINT_RANGE, "0.01,64,0.01"), "set_speed_scale", "get_speed_scale"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "explosiveness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_explosiveness_ratio", "get_explosiveness_ratio"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "randomness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_randomness_ratio", "get_randomness_ratio"); - ADD_PROPERTY(PropertyInfo(Variant::RECT3, "visibility_rect"), "set_visibility_rect", "get_visibility_rect"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates"); ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_fps", PROPERTY_HINT_RANGE, "0,1000,1"), "set_fixed_fps", "get_fixed_fps"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fract_delta"), "set_fractional_delta", "get_fractional_delta"); + ADD_GROUP("Drawing", ""); + ADD_PROPERTY(PropertyInfo(Variant::RECT3, "visibility_rect"), "set_visibility_rect", "get_visibility_rect"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates"); ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime"), "set_draw_order", "get_draw_order"); ADD_GROUP("Process Material", "process_"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "process_material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,ParticlesMaterial"), "set_process_material", "get_process_material"); diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index ff574a6bd6..450f8e2474 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -351,10 +351,12 @@ void Sprite::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_normal_map", "get_normal_map"); + ADD_GROUP("Offset", ""); ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "centered"), "set_centered", "is_centered"); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset"); ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "flip_h"), "set_flip_h", "is_flipped_h"); ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "flip_v"), "set_flip_v", "is_flipped_v"); + ADD_GROUP("Animation", ""); ADD_PROPERTYNO(PropertyInfo(Variant::INT, "vframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_vframes", "get_vframes"); ADD_PROPERTYNO(PropertyInfo(Variant::INT, "hframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_hframes", "get_hframes"); ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), "set_frame", "get_frame"); diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index be24a5f4c1..57e25ec609 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -441,14 +441,15 @@ void TileMap::_update_dirty_quadrants() { rect.position.y -= center.y; } + Ref<Texture> normal_map = tile_set->tile_get_normal_map(c.id); Color modulate = tile_set->tile_get_modulate(c.id); Color self_modulate = get_self_modulate(); modulate = Color(modulate.r * self_modulate.r, modulate.g * self_modulate.g, modulate.b * self_modulate.b, modulate.a * self_modulate.a); if (r == Rect2()) { - tex->draw_rect(canvas_item, rect, false, modulate, c.transpose); + tex->draw_rect(canvas_item, rect, false, modulate, c.transpose, normal_map); } else { - tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose); + tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose, normal_map); } Vector<TileSet::ShapeData> shapes = tile_set->tile_get_shapes(c.id); diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 0d4735fc7f..c291aa33ed 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -309,19 +309,20 @@ void Particles::_bind_methods() { ClassDB::bind_method(D_METHOD("restart"), &Particles::restart); ClassDB::bind_method(D_METHOD("capture_aabb"), &Particles::capture_aabb); - ADD_GROUP("Parameters", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emitting"), "set_emitting", "is_emitting"); ADD_PROPERTY(PropertyInfo(Variant::INT, "amount", PROPERTY_HINT_RANGE, "1,100000,1"), "set_amount", "get_amount"); + ADD_GROUP("Time", ""); ADD_PROPERTY(PropertyInfo(Variant::REAL, "lifetime", PROPERTY_HINT_RANGE, "0.01,600.0,0.01"), "set_lifetime", "get_lifetime"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "one_shot"), "set_one_shot", "get_one_shot"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "preprocess", PROPERTY_HINT_RANGE, "0.00,600.0,0.01"), "set_pre_process_time", "get_pre_process_time"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "speed_scale", PROPERTY_HINT_RANGE, "0.01,64,0.01"), "set_speed_scale", "get_speed_scale"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "explosiveness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_explosiveness_ratio", "get_explosiveness_ratio"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "randomness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_randomness_ratio", "get_randomness_ratio"); - ADD_PROPERTY(PropertyInfo(Variant::RECT3, "visibility_aabb"), "set_visibility_aabb", "get_visibility_aabb"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates"); ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_fps", PROPERTY_HINT_RANGE, "0,1000,1"), "set_fixed_fps", "get_fixed_fps"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fract_delta"), "set_fractional_delta", "get_fractional_delta"); + ADD_GROUP("Drawing", ""); + ADD_PROPERTY(PropertyInfo(Variant::RECT3, "visibility_aabb"), "set_visibility_aabb", "get_visibility_aabb"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates"); ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime,View Depth"), "set_draw_order", "get_draw_order"); ADD_GROUP("Process Material", ""); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "process_material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,ParticlesMaterial"), "set_process_material", "get_process_material"); diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index b6c59ba277..78e8e92afc 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -581,10 +581,12 @@ void Sprite3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_hframes"), &Sprite3D::get_hframes); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); + ADD_GROUP("Animation", ""); ADD_PROPERTY(PropertyInfo(Variant::INT, "vframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_vframes", "get_vframes"); ADD_PROPERTY(PropertyInfo(Variant::INT, "hframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_hframes", "get_hframes"); ADD_PROPERTY(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), "set_frame", "get_frame"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "region"), "set_region", "is_region"); + ADD_GROUP("Region", "region_"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "region_enabled"), "set_region", "is_region"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect"); ADD_SIGNAL(MethodInfo("frame_changed")); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index d864d9fce7..d8788b4eca 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -622,6 +622,40 @@ bool TreeItem::is_custom_set_as_button(int p_column) const { return cells[p_column].custom_button; } +void TreeItem::set_text_align(int p_column, TextAlign p_align) { + ERR_FAIL_INDEX(p_column, cells.size()); + cells[p_column].text_align = p_align; + _changed_notify(p_column); +} + +TreeItem::TextAlign TreeItem::get_text_align(int p_column) const { + ERR_FAIL_INDEX_V(p_column, cells.size(), ALIGN_LEFT); + return cells[p_column].text_align; +} + +void TreeItem::set_expand_right(int p_column, bool p_enable) { + + ERR_FAIL_INDEX(p_column, cells.size()); + cells[p_column].expand_right = p_enable; + _changed_notify(p_column); +} + +bool TreeItem::get_expand_right(int p_column) const { + + ERR_FAIL_INDEX_V(p_column, cells.size(), false); + return cells[p_column].expand_right; +} + +void TreeItem::set_disable_folding(bool p_disable) { + + disable_folding = p_disable; + _changed_notify(0); +} + +bool TreeItem::is_folding_disabled() const { + return disable_folding; +} + void TreeItem::_bind_methods() { ClassDB::bind_method(D_METHOD("set_cell_mode", "column", "mode"), &TreeItem::set_cell_mode); @@ -692,12 +726,19 @@ void TreeItem::_bind_methods() { ClassDB::bind_method(D_METHOD("erase_button", "column", "button_idx"), &TreeItem::erase_button); ClassDB::bind_method(D_METHOD("is_button_disabled", "column", "button_idx"), &TreeItem::is_button_disabled); + ClassDB::bind_method(D_METHOD("set_expand_right", "column", "enable"), &TreeItem::set_expand_right); + ClassDB::bind_method(D_METHOD("get_expand_right", "column"), &TreeItem::get_expand_right); + ClassDB::bind_method(D_METHOD("set_tooltip", "column", "tooltip"), &TreeItem::set_tooltip); ClassDB::bind_method(D_METHOD("get_tooltip", "column"), &TreeItem::get_tooltip); - + ClassDB::bind_method(D_METHOD("set_text_align", "column", "text_align"), &TreeItem::set_text_align); + ClassDB::bind_method(D_METHOD("get_text_align", "column"), &TreeItem::get_text_align); ClassDB::bind_method(D_METHOD("move_to_top"), &TreeItem::move_to_top); ClassDB::bind_method(D_METHOD("move_to_bottom"), &TreeItem::move_to_bottom); + ClassDB::bind_method(D_METHOD("set_disable_folding", "disable"), &TreeItem::set_disable_folding); + ClassDB::bind_method(D_METHOD("is_folding_disabled"), &TreeItem::is_folding_disabled); + BIND_CONSTANT(CELL_MODE_STRING); BIND_CONSTANT(CELL_MODE_CHECK); BIND_CONSTANT(CELL_MODE_RANGE); @@ -724,6 +765,7 @@ TreeItem::TreeItem(Tree *p_tree) { tree = p_tree; collapsed = false; + disable_folding = false; parent = 0; // parent item next = 0; // next in list @@ -894,6 +936,32 @@ int Tree::get_item_height(TreeItem *p_item) const { void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color) { Rect2i rect = p_rect; + Ref<Font> font = cache.font; + String text = p_cell.text; + if (p_cell.suffix != String()) + text += " " + p_cell.suffix; + + int w = 0; + if (!p_cell.icon.is_null()) { + Size2i bmsize = p_cell.get_icon_size(); + + if (p_cell.icon_max_w > 0 && bmsize.width > p_cell.icon_max_w) { + bmsize.width = p_cell.icon_max_w; + } + w += bmsize.width + cache.hseparation; + } + w += font->get_string_size(text).width; + + switch (p_cell.text_align) { + case TreeItem::ALIGN_LEFT: + break; //do none + case TreeItem::ALIGN_CENTER: + rect.position.x = MAX(0, (rect.size.width - w) / 2); + break; //do none + case TreeItem::ALIGN_RIGHT: + rect.position.x = MAX(0, (rect.size.width - w)); + break; //do none + } RID ci = get_canvas_item(); if (!p_cell.icon.is_null()) { @@ -914,12 +982,6 @@ void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, co rect.size.x-=Math::floor(rect.size.y/2); */ - Ref<Font> font = cache.font; - - String text = p_cell.text; - if (p_cell.suffix != String()) - text += " " + p_cell.suffix; - rect.position.y += Math::floor((rect.size.y - font->get_height()) / 2.0) + font->get_ascent(); font->draw(ci, rect.position, text, p_color, rect.size.x); } @@ -970,20 +1032,6 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 if (!skip && (p_pos.y + label_h - cache.offset.y) > 0) { - if (!hide_folding && p_item->childs) { //has childs, draw the guide box - - Ref<Texture> arrow; - - if (p_item->collapsed) { - - arrow = cache.arrow_collapsed; - } else { - arrow = cache.arrow; - } - - arrow->draw(ci, p_pos + p_draw_ofs + Point2i(0, (label_h - arrow->get_height()) / 2) - cache.offset); - } - //draw separation. //if (p_item->get_parent()!=root || !hide_root) @@ -991,9 +1039,15 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 int font_ascent = font->get_ascent(); - int ofs = p_pos.x + (hide_folding ? cache.hseparation : cache.item_margin); + int ofs = p_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin); + int skip = 0; for (int i = 0; i < columns.size(); i++) { + if (skip) { + skip--; + continue; + } + int w = get_column_width(i); if (i == 0) { @@ -1011,6 +1065,16 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 w -= cache.hseparation; } + if (p_item->cells[i].expand_right) { + + int plus = 1; + while (i + plus < columns.size() && !p_item->cells[i + plus].editable && p_item->cells[i + plus].mode == TreeItem::CELL_MODE_STRING && p_item->cells[i + plus].text == "" && p_item->cells[i + plus].icon.is_null()) { + w += get_column_width(i + plus); + plus++; + skip++; + } + } + int bw = 0; for (int j = p_item->cells[i].buttons.size() - 1; j >= 0; j--) { Ref<Texture> b = p_item->cells[i].buttons[j].texture; @@ -1076,8 +1140,13 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 if (p_item->cells[i].custom_bg_color) { Rect2 r = cell_rect; - r.position.x -= cache.hseparation; - r.size.x += cache.hseparation; + if (i == 0) { + r.position.x = p_draw_ofs.x; + r.size.x = w + ofs; + } else { + r.position.x -= cache.hseparation; + r.size.x += cache.hseparation; + } if (p_item->cells[i].custom_bg_outline) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), p_item->cells[i].bg_color); VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y + r.size.y - 1, r.size.x, 1), p_item->cells[i].bg_color); @@ -1274,6 +1343,19 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 } } + if (!p_item->disable_folding && !hide_folding && p_item->childs) { //has childs, draw the guide box + + Ref<Texture> arrow; + + if (p_item->collapsed) { + + arrow = cache.arrow_collapsed; + } else { + arrow = cache.arrow; + } + + arrow->draw(ci, p_pos + p_draw_ofs + Point2i(0, (label_h - arrow->get_height()) / 2) - cache.offset); + } //separator //get_painter()->draw_fill_rect( Point2i(0,pos.y),Size2i(get_size().width,1),color( COLOR_TREE_GRID) ); @@ -1295,8 +1377,8 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 while (c) { if (cache.draw_relationship_lines == 1) { - int root_ofs = children_pos.x + (hide_folding ? cache.hseparation : cache.item_margin); - int parent_ofs = p_pos.x + (hide_folding ? cache.hseparation : cache.item_margin); + int root_ofs = children_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin); + int parent_ofs = p_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin); Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h / 2) - cache.offset + p_draw_ofs; if (c->get_children() != NULL) root_pos -= Point2i(cache.arrow->get_width(), 0); @@ -1488,7 +1570,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool return -1; } - if (!hide_folding && (p_pos.x >= x_ofs && p_pos.x < (x_ofs + cache.item_margin))) { + if (!p_item->disable_folding && !hide_folding && (p_pos.x >= x_ofs && p_pos.x < (x_ofs + cache.item_margin))) { if (p_item->childs) p_item->set_collapsed(!p_item->is_collapsed()); @@ -1504,6 +1586,18 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool for (int i = 0; i < columns.size(); i++) { col_width = get_column_width(i); + + if (p_item->cells[i].expand_right) { + + int plus = 1; + while (i + plus < columns.size() && !p_item->cells[i + plus].editable && p_item->cells[i + plus].mode == TreeItem::CELL_MODE_STRING && p_item->cells[i + plus].text == "" && p_item->cells[i + plus].icon.is_null()) { + plus++; + col_width += cache.hseparation; + col_width += get_column_width(i + plus); + plus++; + } + } + if (x > col_width) { col_ofs += col_width; x -= col_width; @@ -1528,6 +1622,11 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool x -= cache.hseparation; } + if (!p_item->disable_folding && !hide_folding && !p_item->cells[col].editable && !p_item->cells[col].selectable && p_item->get_children()) { + p_item->set_collapsed(!p_item->is_collapsed()); + return -1; //collapse/uncollapse because nothing can be done with item + } + TreeItem::Cell &c = p_item->cells[col]; bool already_selected = c.selected; diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 097e0110e8..59e35bb230 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -58,6 +58,12 @@ public: CELL_MODE_CUSTOM, ///< Contains a custom value, show a string, and an edit button }; + enum TextAlign { + ALIGN_LEFT, + ALIGN_CENTER, + ALIGN_RIGHT + }; + private: friend class Tree; @@ -82,6 +88,9 @@ private: bool custom_bg_outline; Color bg_color; bool custom_button; + bool expand_right; + + TextAlign text_align; Variant meta; String tooltip; @@ -122,6 +131,8 @@ private: custom_bg_color = false; expr = false; icon_max_w = 0; + text_align = ALIGN_LEFT; + expand_right = false; } Size2 get_icon_size() const; @@ -131,6 +142,7 @@ private: Vector<Cell> cells; bool collapsed; // wont show childs + bool disable_folding; TreeItem *parent; // parent item TreeItem *next; // next in list @@ -248,13 +260,23 @@ public: void clear_children(); + void set_text_align(int p_column, TextAlign p_align); + TextAlign get_text_align(int p_column) const; + + void set_expand_right(int p_column, bool p_enable); + bool get_expand_right(int p_column) const; + void move_to_top(); void move_to_bottom(); + void set_disable_folding(bool p_disable); + bool is_folding_disabled() const; + ~TreeItem(); }; VARIANT_ENUM_CAST(TreeItem::TreeCellMode); +VARIANT_ENUM_CAST(TreeItem::TextAlign); class Tree : public Control { diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index ce88325539..0912c70144 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1232,17 +1232,17 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "albedo_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_ALBEDO); ADD_GROUP("Metallic", "metallic_"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "metallic_amount", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_metallic", "get_metallic"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "metallic", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_metallic", "get_metallic"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "metallic_specular", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_specular", "get_specular"); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "metallic_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_METALLIC); ADD_GROUP("Roughness", "roughness_"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "roughness_amount", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_roughness", "get_roughness"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "roughness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_roughness", "get_roughness"); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "roughness_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_ROUGHNESS); ADD_GROUP("Emission", "emission_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "emission_enabled"), "set_feature", "get_feature", FEATURE_EMISSION); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "emission_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_emission", "get_emission"); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "emission", PROPERTY_HINT_COLOR_NO_ALPHA), "set_emission", "get_emission"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "emission_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_emission_energy", "get_emission_energy"); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "emission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_EMISSION); @@ -1253,19 +1253,19 @@ void SpatialMaterial::_bind_methods() { ADD_GROUP("Rim", "rim_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "rim_enabled"), "set_feature", "get_feature", FEATURE_RIM); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "rim_amount", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_rim", "get_rim"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "rim", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_rim", "get_rim"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "rim_tint", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_rim_tint", "get_rim_tint"); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "rim_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_RIM); ADD_GROUP("Clearcoat", "clearcoat_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "clearcoat_enabled"), "set_feature", "get_feature", FEATURE_CLEARCOAT); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "clearcoat_amount", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_clearcoat", "get_clearcoat"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "clearcoat", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_clearcoat", "get_clearcoat"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "clearcoat_gloss", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_clearcoat_gloss", "get_clearcoat_gloss"); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "clearcoat_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_CLEARCOAT); ADD_GROUP("Anisotropy", "anisotropy_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "anisotropy_enabled"), "set_feature", "get_feature", FEATURE_ANISOTROPY); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "anisotropy_anisotropy", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_anisotropy", "get_anisotropy"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "anisotropy", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_anisotropy", "get_anisotropy"); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "anisotropy_flowmap", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_FLOWMAP); ADD_GROUP("Ambient Occlusion", "ao_"); diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 894388e890..b9d2c503e1 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -45,6 +45,8 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { tile_set_name(id, p_value); else if (what == "texture") tile_set_texture(id, p_value); + else if (what == "normal_map") + tile_set_normal_map(id, p_value); else if (what == "tex_offset") tile_set_texture_offset(id, p_value); else if (what == "material") @@ -91,6 +93,8 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const { r_ret = tile_get_name(id); else if (what == "texture") r_ret = tile_get_texture(id); + else if (what == "normal_map") + r_ret = tile_get_normal_map(id); else if (what == "tex_offset") r_ret = tile_get_texture_offset(id); else if (what == "material") @@ -129,6 +133,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const { String pre = itos(id) + "/"; p_list->push_back(PropertyInfo(Variant::STRING, pre + "name")); p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture")); + p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture")); p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "tex_offset")); p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial")); p_list->push_back(PropertyInfo(Variant::COLOR, pre + "modulate")); @@ -165,6 +170,19 @@ Ref<Texture> TileSet::tile_get_texture(int p_id) const { return tile_map[p_id].texture; } +void TileSet::tile_set_normal_map(int p_id, const Ref<Texture> &p_normal_map) { + + ERR_FAIL_COND(!tile_map.has(p_id)); + tile_map[p_id].normal_map = p_normal_map; + emit_changed(); +} + +Ref<Texture> TileSet::tile_get_normal_map(int p_id) const { + + ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture>()); + return tile_map[p_id].normal_map; +} + void TileSet::tile_set_material(int p_id, const Ref<ShaderMaterial> &p_material) { ERR_FAIL_COND(!tile_map.has(p_id)); @@ -492,6 +510,8 @@ void TileSet::_bind_methods() { ClassDB::bind_method(D_METHOD("tile_get_name", "id"), &TileSet::tile_get_name); ClassDB::bind_method(D_METHOD("tile_set_texture", "id", "texture:Texture"), &TileSet::tile_set_texture); ClassDB::bind_method(D_METHOD("tile_get_texture:Texture", "id"), &TileSet::tile_get_texture); + ClassDB::bind_method(D_METHOD("tile_set_normal_map", "id", "normal_map:Texture"), &TileSet::tile_set_normal_map); + ClassDB::bind_method(D_METHOD("tile_get_normal_map:Texture", "id"), &TileSet::tile_get_normal_map); ClassDB::bind_method(D_METHOD("tile_set_material", "id", "material:ShaderMaterial"), &TileSet::tile_set_material); ClassDB::bind_method(D_METHOD("tile_get_material:ShaderMaterial", "id"), &TileSet::tile_get_material); ClassDB::bind_method(D_METHOD("tile_set_texture_offset", "id", "texture_offset"), &TileSet::tile_set_texture_offset); diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h index 86903dd8ea..c07d82c75a 100644 --- a/scene/resources/tile_set.h +++ b/scene/resources/tile_set.h @@ -56,6 +56,7 @@ private: String name; Ref<Texture> texture; + Ref<Texture> normal_map; Vector2 offset; Rect2i region; Vector<ShapeData> shapes_data; @@ -92,6 +93,9 @@ public: void tile_set_texture(int p_id, const Ref<Texture> &p_texture); Ref<Texture> tile_get_texture(int p_id) const; + void tile_set_normal_map(int p_id, const Ref<Texture> &p_normal_map); + Ref<Texture> tile_get_normal_map(int p_id) const; + void tile_set_texture_offset(int p_id, const Vector2 &p_offset); Vector2 tile_get_texture_offset(int p_id) const; |