summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/default_theme/default_theme.cpp3
-rw-r--r--scene/resources/shape_2d.cpp62
-rw-r--r--scene/resources/shape_2d.h6
-rw-r--r--scene/resources/theme.cpp51
-rw-r--r--scene/resources/theme.h7
-rw-r--r--scene/resources/tile_set.cpp51
-rw-r--r--scene/resources/tile_set.h9
7 files changed, 171 insertions, 18 deletions
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 01f0869275..3c992a93b9 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -196,7 +196,7 @@ void make_default_theme() {
focus->set_expand_margin_size(Margin(i),2);
}
t->set_stylebox("focus","Button", focus );
- t->set_font("font","Button", focus );
+ t->set_font("font","Button", default_font );
t->set_color("font_color","Button", control_font_color );
t->set_color("font_color_pressed","Button", control_font_color_pressed );
t->set_color("font_color_hover","Button", control_font_color_hover );
@@ -533,6 +533,7 @@ void make_default_theme() {
t->set_color("font_color_selected","RichTextLabel", font_color_selection );
t->set_color("selection_color","RichTextLabel", Color(0.1,0.1,1,0.8) );
t->set_constant("line_separation","RichTextLabel", 1 );
+ t->set_stylebox("focus","RichTextLabel", focus );
t->set_constant("separation","HBoxContainer",4);
diff --git a/scene/resources/shape_2d.cpp b/scene/resources/shape_2d.cpp
index d876454954..ca891920da 100644
--- a/scene/resources/shape_2d.cpp
+++ b/scene/resources/shape_2d.cpp
@@ -47,20 +47,82 @@ real_t Shape2D::get_custom_solver_bias() const{
}
+bool Shape2D::collide_with_motion(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_shape_motion) {
+
+ ERR_FAIL_COND_V(p_shape.is_null(),false);
+ int r;
+ return Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,p_local_motion,p_shape->get_rid(),p_shape_xform,p_shape_motion,NULL,0,r);
+}
+
+bool Shape2D::collide(const Matrix32& p_local_xform, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform){
+ ERR_FAIL_COND_V(p_shape.is_null(),false);
+ int r;
+ return Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,Vector2(),p_shape->get_rid(),p_shape_xform,Vector2(),NULL,0,r);
+
+
+}
+
+Variant Shape2D::collide_with_motion_and_get_contacts(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_shape_motion){
+
+ ERR_FAIL_COND_V(p_shape.is_null(),Variant());
+ const int max_contacts = 16;
+ Vector2 result[max_contacts*2];
+ int contacts=0;
+
+ if (!Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,p_local_motion,p_shape->get_rid(),p_shape_xform,p_shape_motion,result,max_contacts,contacts))
+ return Variant();
+
+ Array results;
+ results.resize(contacts*2);
+ for(int i=0;i<contacts;i++) {
+ results[i]=result[i];
+ }
+
+ return results;
+
+}
+Variant Shape2D::collide_and_get_contacts(const Matrix32& p_local_xform, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform){
+
+ ERR_FAIL_COND_V(p_shape.is_null(),Variant());
+ const int max_contacts = 16;
+ Vector2 result[max_contacts*2];
+ int contacts=0;
+
+ if (!Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,Vector2(),p_shape->get_rid(),p_shape_xform,Vector2(),result,max_contacts,contacts))
+ return Variant();
+
+ Array results;
+ results.resize(contacts*2);
+ for(int i=0;i<contacts;i++) {
+ results[i]=result[i];
+ }
+
+ return results;
+
+
+}
+
void Shape2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_custom_solver_bias","bias"),&Shape2D::set_custom_solver_bias);
ObjectTypeDB::bind_method(_MD("get_custom_solver_bias"),&Shape2D::get_custom_solver_bias);
+ ObjectTypeDB::bind_method(_MD("collide","local_xform","with_shape:Shape2D","shape_xform"),&Shape2D::collide);
+ ObjectTypeDB::bind_method(_MD("collide_with_motion","local_xform","local_motion","with_shape:Shape2D","shape_xform","shape_motion"),&Shape2D::collide_with_motion);
+ ObjectTypeDB::bind_method(_MD("collide_and_get_contacts:var","local_xform","with_shape:Shape2D","shape_xform"),&Shape2D::collide_and_get_contacts);
+ ObjectTypeDB::bind_method(_MD("collide_with_motion_and_get_contacts:var","local_xform","local_motion","with_shape:Shape2D","shape_xform","shape_motion"),&Shape2D::collide_and_get_contacts);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"custom_solver_bias",PROPERTY_HINT_RANGE,"0,1,0.001"),_SCS("set_custom_solver_bias"),_SCS("get_custom_solver_bias"));
}
+
+
Shape2D::Shape2D(const RID& p_rid) {
shape=p_rid;
custom_bias=0;
}
+
Shape2D::~Shape2D() {
Physics2DServer::get_singleton()->free(shape);
diff --git a/scene/resources/shape_2d.h b/scene/resources/shape_2d.h
index b01820c22c..5f254a1572 100644
--- a/scene/resources/shape_2d.h
+++ b/scene/resources/shape_2d.h
@@ -47,6 +47,12 @@ public:
void set_custom_solver_bias(real_t p_bias);
real_t get_custom_solver_bias() const;
+ bool collide_with_motion(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_p_shape_motion);
+ bool collide(const Matrix32& p_local_xform, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform);
+
+ Variant collide_with_motion_and_get_contacts(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_p_shape_motion);
+ Variant collide_and_get_contacts(const Matrix32& p_local_xform, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform);
+
virtual RID get_rid() const;
Shape2D();
~Shape2D();
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index c711bf5af1..f6e0293dd9 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -130,6 +130,7 @@ void Theme::_get_property_list( List<PropertyInfo> *p_list) const {
}
key=NULL;
+
while((key=font_map.next(key))) {
@@ -172,6 +173,17 @@ Ref<Theme> Theme::get_default() {
return default_theme;
}
+
+void Theme::set_default_theme_font( const Ref<Font>& p_default_font ) {
+
+ default_theme_font=p_default_font;
+}
+
+Ref<Font> Theme::get_default_theme_font() const {
+
+ return default_theme_font;
+}
+
void Theme::set_default(const Ref<Theme>& p_default) {
default_theme=p_default;
@@ -203,8 +215,10 @@ void Theme::set_icon(const StringName& p_name,const StringName& p_type,const Ref
icon_map[p_type][p_name]=p_icon;
- if (new_value)
+ if (new_value) {
_change_notify();
+ emit_changed();;
+ }
}
Ref<Texture> Theme::get_icon(const StringName& p_name,const StringName& p_type) const {
@@ -229,6 +243,8 @@ void Theme::clear_icon(const StringName& p_name,const StringName& p_type) {
icon_map[p_type].erase(p_name);
_change_notify();
+ emit_changed();;
+
}
void Theme::get_icon_list(StringName p_type, List<StringName> *p_list) const {
@@ -256,6 +272,8 @@ void Theme::set_stylebox(const StringName& p_name,const StringName& p_type,const
if (new_value)
_change_notify();
+ emit_changed();;
+
}
@@ -281,6 +299,8 @@ void Theme::clear_stylebox(const StringName& p_name,const StringName& p_type) {
style_map[p_type].erase(p_name);
_change_notify();
+ emit_changed();;
+
}
void Theme::get_stylebox_list(StringName p_type, List<StringName> *p_list) const {
@@ -304,13 +324,18 @@ void Theme::set_font(const StringName& p_name,const StringName& p_type,const Ref
bool new_value=!font_map.has(p_type) || !font_map[p_type].has(p_name);
font_map[p_type][p_name]=p_font;
- if (new_value)
+ if (new_value) {
_change_notify();
+ emit_changed();;
+
+ }
}
Ref<Font> Theme::get_font(const StringName& p_name,const StringName& p_type) const {
if (font_map.has(p_type) && font_map[p_type].has(p_name) && font_map[p_type][p_name].is_valid())
return font_map[p_type][p_name];
+ else if (default_theme_font.is_valid())
+ return default_theme_font;
else
return default_font;
@@ -328,6 +353,8 @@ void Theme::clear_font(const StringName& p_name,const StringName& p_type) {
font_map[p_type].erase(p_name);
_change_notify();
+ emit_changed();;
+
}
void Theme::get_font_list(StringName p_type, List<StringName> *p_list) const {
@@ -350,8 +377,11 @@ void Theme::set_color(const StringName& p_name,const StringName& p_type,const Co
color_map[p_type][p_name]=p_color;
- if (new_value)
+ if (new_value) {
_change_notify();
+ emit_changed();;
+
+ }
}
@@ -377,6 +407,8 @@ void Theme::clear_color(const StringName& p_name,const StringName& p_type) {
color_map[p_type].erase(p_name);
_change_notify();
+ emit_changed();;
+
}
void Theme::get_color_list(StringName p_type, List<StringName> *p_list) const {
@@ -398,8 +430,10 @@ void Theme::set_constant(const StringName& p_name,const StringName& p_type,int p
bool new_value=!constant_map.has(p_type) || !constant_map[p_type].has(p_name);
constant_map[p_type][p_name]=p_constant;
- if (new_value)
+ if (new_value) {
_change_notify();
+ emit_changed();;
+ }
}
int Theme::get_constant(const StringName& p_name,const StringName& p_type) const {
@@ -424,6 +458,8 @@ void Theme::clear_constant(const StringName& p_name,const StringName& p_type) {
constant_map[p_type].erase(p_name);
_change_notify();
+ emit_changed();;
+
}
void Theme::get_constant_list(StringName p_type, List<StringName> *p_list) const {
@@ -451,6 +487,8 @@ void Theme::copy_default_theme() {
color_map=default_theme->color_map;
constant_map=default_theme->constant_map;
_change_notify();
+ emit_changed();;
+
}
void Theme::get_type_list(List<StringName> *p_list) const {
@@ -532,10 +570,15 @@ void Theme::_bind_methods() {
ObjectTypeDB::bind_method(_MD("clear_constant","name","type"),&Theme::clear_constant);
ObjectTypeDB::bind_method(_MD("get_constant_list"),&Theme::_get_constant_list);
+ ObjectTypeDB::bind_method(_MD("set_default_font","font"),&Theme::set_default_theme_font);
+ ObjectTypeDB::bind_method(_MD("get_default_font"),&Theme::get_default_theme_font);
+
ObjectTypeDB::bind_method(_MD("get_type_list"),&Theme::_get_type_list);
ObjectTypeDB::bind_method("copy_default_theme",&Theme::copy_default_theme);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"default_font",PROPERTY_HINT_RESOURCE_TYPE,"Font"),_SCS("set_default_font"),_SCS("get_default_font"));
+
}
Theme::Theme() {
diff --git a/scene/resources/theme.h b/scene/resources/theme.h
index c9d147689e..b2df917511 100644
--- a/scene/resources/theme.h
+++ b/scene/resources/theme.h
@@ -59,6 +59,7 @@ protected:
static Ref<StyleBox> default_style;
static Ref<Font> default_font;
+ Ref<Font> default_theme_font;
DVector<String> _get_icon_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_icon_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
DVector<String> _get_stylebox_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_stylebox_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
@@ -76,8 +77,10 @@ public:
static void set_default_icon( const Ref<Texture>& p_icon );
static void set_default_style( const Ref<StyleBox>& p_default_style);
static void set_default_font( const Ref<Font>& p_default_font );
-
-
+
+ void set_default_theme_font( const Ref<Font>& p_default_font );
+ Ref<Font> get_default_theme_font() const;
+
void set_icon(const StringName& p_name,const StringName& p_type,const Ref<Texture>& p_icon);
Ref<Texture> get_icon(const StringName& p_name,const StringName& p_type) const;
bool has_icon(const StringName& p_name,const StringName& p_type) const;
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index e3c27b0c0c..208ba5bb66 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -44,8 +44,10 @@ 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=="offset")
- tile_set_offset(id,p_value);
+ else if (what=="tex_offset")
+ tile_set_texture_offset(id,p_value);
+ else if (what=="shape_offset")
+ tile_set_shape_offset(id,p_value);
else if (what=="region")
tile_set_region(id,p_value);
else if (what=="shape")
@@ -75,8 +77,10 @@ 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=="offset")
- r_ret=tile_get_offset(id);
+ else if (what=="tex_offset")
+ r_ret=tile_get_texture_offset(id);
+ else if (what=="shape_offset")
+ r_ret=tile_get_shape_offset(id);
else if (what=="region")
r_ret=tile_get_region(id);
else if (what=="shape")
@@ -98,7 +102,8 @@ 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::VECTOR2,pre+"offset"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"tex_offset"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"shape_offset"));
p_list->push_back(PropertyInfo(Variant::RECT2,pre+"region"));
p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape2D",PROPERTY_USAGE_EDITOR));
p_list->push_back(PropertyInfo(Variant::ARRAY,pre+"shapes",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
@@ -129,20 +134,34 @@ Ref<Texture> TileSet::tile_get_texture(int p_id) const {
}
-void TileSet::tile_set_offset(int p_id,const Vector2 &p_offset) {
+void TileSet::tile_set_texture_offset(int p_id,const Vector2 &p_offset) {
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].offset=p_offset;
emit_changed();
}
-Vector2 TileSet::tile_get_offset(int p_id) const {
+Vector2 TileSet::tile_get_texture_offset(int p_id) const {
ERR_FAIL_COND_V(!tile_map.has(p_id),Vector2());
return tile_map[p_id].offset;
}
+void TileSet::tile_set_shape_offset(int p_id,const Vector2 &p_offset) {
+
+ ERR_FAIL_COND(!tile_map.has(p_id));
+ tile_map[p_id].shape_offset=p_offset;
+ emit_changed();
+}
+
+Vector2 TileSet::tile_get_shape_offset(int p_id) const {
+
+ ERR_FAIL_COND_V(!tile_map.has(p_id),Vector2());
+ return tile_map[p_id].shape_offset;
+
+}
+
void TileSet::tile_set_region(int p_id,const Rect2 &p_region) {
ERR_FAIL_COND(!tile_map.has(p_id));
@@ -231,6 +250,17 @@ Array TileSet::_tile_get_shapes(int p_id) const{
return arr;
}
+Array TileSet::_get_tiles_ids() const{
+
+ Array arr;
+
+ for (Map<int, Data>::Element *E = tile_map.front(); E; E = E->next()) {
+ arr.push_back(E->key());
+ }
+
+ return arr;
+}
+
void TileSet::get_tile_list(List<int> *p_tiles) const {
for(Map<int,Data>::Element *E=tile_map.front();E;E=E->next()) {
@@ -289,8 +319,10 @@ void TileSet::_bind_methods() {
ObjectTypeDB::bind_method(_MD("tile_get_name","id"),&TileSet::tile_get_name);
ObjectTypeDB::bind_method(_MD("tile_set_texture","id","texture:Texture"),&TileSet::tile_set_texture);
ObjectTypeDB::bind_method(_MD("tile_get_texture:Texture","id"),&TileSet::tile_get_texture);
- ObjectTypeDB::bind_method(_MD("tile_set_offset","id","offset"),&TileSet::tile_set_offset);
- ObjectTypeDB::bind_method(_MD("tile_get_offset","id"),&TileSet::tile_get_offset);
+ ObjectTypeDB::bind_method(_MD("tile_set_texture_offset","id","texture_offset"),&TileSet::tile_set_texture_offset);
+ ObjectTypeDB::bind_method(_MD("tile_get_texture_offset","id"),&TileSet::tile_get_texture_offset);
+ ObjectTypeDB::bind_method(_MD("tile_set_shape_offset","id","shape_offset"),&TileSet::tile_set_shape_offset);
+ ObjectTypeDB::bind_method(_MD("tile_get_shape_offset","id"),&TileSet::tile_get_shape_offset);
ObjectTypeDB::bind_method(_MD("tile_set_region","id","region"),&TileSet::tile_set_region);
ObjectTypeDB::bind_method(_MD("tile_get_region","id"),&TileSet::tile_get_region);
ObjectTypeDB::bind_method(_MD("tile_set_shape","id","shape:Shape2D"),&TileSet::tile_set_shape);
@@ -301,6 +333,7 @@ void TileSet::_bind_methods() {
ObjectTypeDB::bind_method(_MD("clear"),&TileSet::clear);
ObjectTypeDB::bind_method(_MD("get_last_unused_tile_id"),&TileSet::get_last_unused_tile_id);
ObjectTypeDB::bind_method(_MD("find_tile_by_name","name"),&TileSet::find_tile_by_name);
+ ObjectTypeDB::bind_method(_MD("get_tiles_ids", "name"), &TileSet::_get_tiles_ids);
}
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index e674316519..ddbb1b59a6 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -42,6 +42,7 @@ class TileSet : public Resource {
String name;
Ref<Texture> texture;
Vector2 offset;
+ Vector2 shape_offset;
Rect2i region;
Vector<Ref<Shape2D> > shapes;
};
@@ -56,6 +57,7 @@ protected:
void _get_property_list( List<PropertyInfo> *p_list) const;
void _tile_set_shapes(int p_id,const Array& p_shapes);
Array _tile_get_shapes(int p_id) const;
+ Array _get_tiles_ids() const;
static void _bind_methods();
public:
@@ -70,8 +72,11 @@ 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_offset(int p_id,const Vector2 &p_offset);
- Vector2 tile_get_offset(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;
+
+ void tile_set_shape_offset(int p_id,const Vector2 &p_offset);
+ Vector2 tile_get_shape_offset(int p_id) const;
void tile_set_region(int p_id,const Rect2 &p_region);
Rect2 tile_get_region(int p_id) const;