1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-25 15:37:42 +00:00

Bring that Whole New World to the Old Continent too

Applies the clang-format style to the 2.1 branch as done for master in
5dbf1809c6.
This commit is contained in:
Rémi Verschelde
2017-03-19 00:36:26 +01:00
parent 1d418afe86
commit f8db8a3faa
1308 changed files with 147754 additions and 174357 deletions

View File

@@ -29,16 +29,13 @@
#include "parallax_background.h"
#include "parallax_layer.h"
void ParallaxBackground::_notification(int p_what) {
switch(p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
group_name = "__cameras_"+itos(get_viewport().get_id());
group_name = "__cameras_" + itos(get_viewport().get_id());
add_to_group(group_name);
} break;
@@ -47,31 +44,27 @@ void ParallaxBackground::_notification(int p_what) {
remove_from_group(group_name);
} break;
}
}
void ParallaxBackground::_camera_moved(const Matrix32& p_transform) {
void ParallaxBackground::_camera_moved(const Matrix32 &p_transform) {
set_scroll_offset(p_transform.get_origin());
set_scroll_scale(p_transform.get_scale().dot(Vector2(0.5,0.5)));
set_scroll_scale(p_transform.get_scale().dot(Vector2(0.5, 0.5)));
}
void ParallaxBackground::set_scroll_scale(float p_scale) {
scale=p_scale;
scale = p_scale;
}
float ParallaxBackground::get_scroll_scale() const{
float ParallaxBackground::get_scroll_scale() const {
return scale;
}
void ParallaxBackground::set_scroll_offset(const Point2 &p_ofs) {
void ParallaxBackground::set_scroll_offset(const Point2& p_ofs) {
offset=p_ofs;
offset = p_ofs;
_update_scroll();
}
@@ -81,7 +74,7 @@ void ParallaxBackground::_update_scroll() {
if (!is_inside_tree())
return;
Vector2 ofs = base_offset+offset*base_scale;
Vector2 ofs = base_offset + offset * base_scale;
Size2 vps = get_viewport_size();
@@ -89,26 +82,25 @@ void ParallaxBackground::_update_scroll() {
if (limit_begin.x < limit_end.x) {
if (ofs.x < limit_begin.x)
ofs.x=limit_begin.x;
else if (ofs.x+vps.x > limit_end.x)
ofs.x=limit_end.x-vps.x;
ofs.x = limit_begin.x;
else if (ofs.x + vps.x > limit_end.x)
ofs.x = limit_end.x - vps.x;
}
if (limit_begin.y < limit_end.y) {
if (ofs.y < limit_begin.y)
ofs.y=limit_begin.y;
else if (ofs.y+vps.y > limit_end.y)
ofs.y=limit_end.y-vps.y;
ofs.y = limit_begin.y;
else if (ofs.y + vps.y > limit_end.y)
ofs.y = limit_end.y - vps.y;
}
ofs = -ofs;
final_offset=ofs;
final_offset = ofs;
for(int i=0;i<get_child_count();i++) {
for (int i = 0; i < get_child_count(); i++) {
ParallaxLayer *l=get_child(i)->cast_to<ParallaxLayer>();
ParallaxLayer *l = get_child(i)->cast_to<ParallaxLayer>();
if (!l)
continue;
@@ -124,32 +116,31 @@ Point2 ParallaxBackground::get_scroll_offset() const {
return offset;
}
void ParallaxBackground::set_scroll_base_offset(const Point2& p_ofs) {
void ParallaxBackground::set_scroll_base_offset(const Point2 &p_ofs) {
base_offset=p_ofs;
base_offset = p_ofs;
_update_scroll();
}
Point2 ParallaxBackground::get_scroll_base_offset() const{
Point2 ParallaxBackground::get_scroll_base_offset() const {
return base_offset;
}
void ParallaxBackground::set_scroll_base_scale(const Point2& p_ofs) {
void ParallaxBackground::set_scroll_base_scale(const Point2 &p_ofs) {
base_scale=p_ofs;
base_scale = p_ofs;
_update_scroll();
}
Point2 ParallaxBackground::get_scroll_base_scale() const{
Point2 ParallaxBackground::get_scroll_base_scale() const {
return base_scale;
}
void ParallaxBackground::set_limit_begin(const Point2 &p_ofs) {
void ParallaxBackground::set_limit_begin(const Point2& p_ofs) {
limit_begin=p_ofs;
limit_begin = p_ofs;
_update_scroll();
}
@@ -158,11 +149,10 @@ Point2 ParallaxBackground::get_limit_begin() const {
return limit_begin;
}
void ParallaxBackground::set_limit_end(const Point2& p_ofs) {
void ParallaxBackground::set_limit_end(const Point2 &p_ofs) {
limit_end=p_ofs;
limit_end = p_ofs;
_update_scroll();
}
Point2 ParallaxBackground::get_limit_end() const {
@@ -170,16 +160,14 @@ Point2 ParallaxBackground::get_limit_end() const {
return limit_end;
}
void ParallaxBackground::set_ignore_camera_zoom(bool ignore){
ignore_camera_zoom = ignore;
void ParallaxBackground::set_ignore_camera_zoom(bool ignore) {
ignore_camera_zoom = ignore;
}
bool ParallaxBackground::is_ignore_camera_zoom(){
return ignore_camera_zoom;
bool ParallaxBackground::is_ignore_camera_zoom() {
return ignore_camera_zoom;
}
Vector2 ParallaxBackground::get_final_offset() const {
@@ -189,37 +177,31 @@ Vector2 ParallaxBackground::get_final_offset() const {
void ParallaxBackground::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_camera_moved"),&ParallaxBackground::_camera_moved);
ObjectTypeDB::bind_method(_MD("set_scroll_offset","ofs"),&ParallaxBackground::set_scroll_offset);
ObjectTypeDB::bind_method(_MD("get_scroll_offset"),&ParallaxBackground::get_scroll_offset);
ObjectTypeDB::bind_method(_MD("set_scroll_base_offset","ofs"),&ParallaxBackground::set_scroll_base_offset);
ObjectTypeDB::bind_method(_MD("get_scroll_base_offset"),&ParallaxBackground::get_scroll_base_offset);
ObjectTypeDB::bind_method(_MD("set_scroll_base_scale","scale"),&ParallaxBackground::set_scroll_base_scale);
ObjectTypeDB::bind_method(_MD("get_scroll_base_scale"),&ParallaxBackground::get_scroll_base_scale);
ObjectTypeDB::bind_method(_MD("set_limit_begin","ofs"),&ParallaxBackground::set_limit_begin);
ObjectTypeDB::bind_method(_MD("get_limit_begin"),&ParallaxBackground::get_limit_begin);
ObjectTypeDB::bind_method(_MD("set_limit_end","ofs"),&ParallaxBackground::set_limit_end);
ObjectTypeDB::bind_method(_MD("get_limit_end"),&ParallaxBackground::get_limit_end);
ObjectTypeDB::bind_method(_MD("set_ignore_camera_zoom","ignore"), &ParallaxBackground::set_ignore_camera_zoom);
ObjectTypeDB::bind_method(_MD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom);
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/offset"),_SCS("set_scroll_offset"),_SCS("get_scroll_offset"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/base_offset"),_SCS("set_scroll_base_offset"),_SCS("get_scroll_base_offset"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/base_scale"),_SCS("set_scroll_base_scale"),_SCS("get_scroll_base_scale"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_begin"),_SCS("set_limit_begin"),_SCS("get_limit_begin"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_end"),_SCS("set_limit_end"),_SCS("get_limit_end"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL, "scroll/ignore_camera_zoom"), _SCS("set_ignore_camera_zoom"), _SCS("is_ignore_camera_zoom"));
ObjectTypeDB::bind_method(_MD("_camera_moved"), &ParallaxBackground::_camera_moved);
ObjectTypeDB::bind_method(_MD("set_scroll_offset", "ofs"), &ParallaxBackground::set_scroll_offset);
ObjectTypeDB::bind_method(_MD("get_scroll_offset"), &ParallaxBackground::get_scroll_offset);
ObjectTypeDB::bind_method(_MD("set_scroll_base_offset", "ofs"), &ParallaxBackground::set_scroll_base_offset);
ObjectTypeDB::bind_method(_MD("get_scroll_base_offset"), &ParallaxBackground::get_scroll_base_offset);
ObjectTypeDB::bind_method(_MD("set_scroll_base_scale", "scale"), &ParallaxBackground::set_scroll_base_scale);
ObjectTypeDB::bind_method(_MD("get_scroll_base_scale"), &ParallaxBackground::get_scroll_base_scale);
ObjectTypeDB::bind_method(_MD("set_limit_begin", "ofs"), &ParallaxBackground::set_limit_begin);
ObjectTypeDB::bind_method(_MD("get_limit_begin"), &ParallaxBackground::get_limit_begin);
ObjectTypeDB::bind_method(_MD("set_limit_end", "ofs"), &ParallaxBackground::set_limit_end);
ObjectTypeDB::bind_method(_MD("get_limit_end"), &ParallaxBackground::get_limit_end);
ObjectTypeDB::bind_method(_MD("set_ignore_camera_zoom", "ignore"), &ParallaxBackground::set_ignore_camera_zoom);
ObjectTypeDB::bind_method(_MD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scroll/offset"), _SCS("set_scroll_offset"), _SCS("get_scroll_offset"));
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scroll/base_offset"), _SCS("set_scroll_base_offset"), _SCS("get_scroll_base_offset"));
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scroll/base_scale"), _SCS("set_scroll_base_scale"), _SCS("get_scroll_base_scale"));
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scroll/limit_begin"), _SCS("set_limit_begin"), _SCS("get_limit_begin"));
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scroll/limit_end"), _SCS("set_limit_end"), _SCS("get_limit_end"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll/ignore_camera_zoom"), _SCS("set_ignore_camera_zoom"), _SCS("is_ignore_camera_zoom"));
}
ParallaxBackground::ParallaxBackground() {
base_scale=Vector2(1,1);
scale=1.0;
base_scale = Vector2(1, 1);
scale = 1.0;
set_layer(-1); //behind all by default
}