You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-24 15:26:15 +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:
@@ -29,42 +29,38 @@
|
||||
#include "parallax_layer.h"
|
||||
#include "parallax_background.h"
|
||||
|
||||
void ParallaxLayer::set_motion_scale(const Size2& p_scale) {
|
||||
|
||||
motion_scale=p_scale;
|
||||
void ParallaxLayer::set_motion_scale(const Size2 &p_scale) {
|
||||
|
||||
motion_scale = p_scale;
|
||||
|
||||
ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
|
||||
if (is_inside_tree() && pb) {
|
||||
Vector2 ofs = pb->get_final_offset();
|
||||
float scale = pb->get_scroll_scale();
|
||||
set_base_offset_and_scale(ofs,scale);
|
||||
set_base_offset_and_scale(ofs, scale);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Size2 ParallaxLayer::get_motion_scale() const {
|
||||
|
||||
return motion_scale;
|
||||
|
||||
}
|
||||
|
||||
void ParallaxLayer::set_motion_offset(const Size2& p_offset) {
|
||||
void ParallaxLayer::set_motion_offset(const Size2 &p_offset) {
|
||||
|
||||
motion_offset=p_offset;
|
||||
motion_offset = p_offset;
|
||||
|
||||
ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
|
||||
if (is_inside_tree() && pb) {
|
||||
Vector2 ofs = pb->get_final_offset();
|
||||
float scale = pb->get_scroll_scale();
|
||||
set_base_offset_and_scale(ofs,scale);
|
||||
set_base_offset_and_scale(ofs, scale);
|
||||
}
|
||||
}
|
||||
|
||||
Size2 ParallaxLayer::get_motion_offset() const {
|
||||
|
||||
return motion_offset;
|
||||
|
||||
}
|
||||
|
||||
void ParallaxLayer::_update_mirroring() {
|
||||
@@ -77,68 +73,61 @@ void ParallaxLayer::_update_mirroring() {
|
||||
|
||||
RID c = pb->get_world_2d()->get_canvas();
|
||||
RID ci = get_canvas_item();
|
||||
VisualServer::get_singleton()->canvas_set_item_mirroring(c,ci,mirroring);
|
||||
VisualServer::get_singleton()->canvas_set_item_mirroring(c, ci, mirroring);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ParallaxLayer::set_mirroring(const Size2& p_mirroring) {
|
||||
void ParallaxLayer::set_mirroring(const Size2 &p_mirroring) {
|
||||
|
||||
mirroring=p_mirroring;
|
||||
if (mirroring.x<0)
|
||||
mirroring.x=0;
|
||||
if (mirroring.y<0)
|
||||
mirroring.y=0;
|
||||
mirroring = p_mirroring;
|
||||
if (mirroring.x < 0)
|
||||
mirroring.x = 0;
|
||||
if (mirroring.y < 0)
|
||||
mirroring.y = 0;
|
||||
|
||||
_update_mirroring();
|
||||
|
||||
}
|
||||
|
||||
Size2 ParallaxLayer::get_mirroring() const{
|
||||
Size2 ParallaxLayer::get_mirroring() const {
|
||||
|
||||
return mirroring;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ParallaxLayer::_notification(int p_what) {
|
||||
|
||||
switch(p_what) {
|
||||
switch (p_what) {
|
||||
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
|
||||
orig_offset=get_pos();
|
||||
orig_scale=get_scale();
|
||||
orig_offset = get_pos();
|
||||
orig_scale = get_scale();
|
||||
_update_mirroring();
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void ParallaxLayer::set_base_offset_and_scale(const Point2& p_offset,float p_scale) {
|
||||
void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, float p_scale) {
|
||||
|
||||
if (!is_inside_tree())
|
||||
return;
|
||||
if (get_tree()->is_editor_hint())
|
||||
return;
|
||||
Point2 new_ofs = ((orig_offset+p_offset)*motion_scale)*p_scale+motion_offset;
|
||||
Point2 new_ofs = ((orig_offset + p_offset) * motion_scale) * p_scale + motion_offset;
|
||||
|
||||
if (mirroring.x) {
|
||||
double den = mirroring.x*p_scale;
|
||||
new_ofs.x -= den*ceil(new_ofs.x/den);
|
||||
double den = mirroring.x * p_scale;
|
||||
new_ofs.x -= den * ceil(new_ofs.x / den);
|
||||
}
|
||||
|
||||
if (mirroring.y) {
|
||||
double den = mirroring.y*p_scale;
|
||||
new_ofs.y -= den*ceil(new_ofs.y/den);
|
||||
double den = mirroring.y * p_scale;
|
||||
new_ofs.y -= den * ceil(new_ofs.y / den);
|
||||
}
|
||||
|
||||
set_pos(new_ofs);
|
||||
set_scale(Vector2(1,1)*p_scale);
|
||||
|
||||
|
||||
set_scale(Vector2(1, 1) * p_scale);
|
||||
}
|
||||
|
||||
|
||||
String ParallaxLayer::get_configuration_warning() const {
|
||||
|
||||
if (!get_parent() || !get_parent()->cast_to<ParallaxBackground>()) {
|
||||
@@ -150,22 +139,18 @@ String ParallaxLayer::get_configuration_warning() const {
|
||||
|
||||
void ParallaxLayer::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_motion_scale","scale"),&ParallaxLayer::set_motion_scale);
|
||||
ObjectTypeDB::bind_method(_MD("get_motion_scale"),&ParallaxLayer::get_motion_scale);
|
||||
ObjectTypeDB::bind_method(_MD("set_motion_offset","offset"),&ParallaxLayer::set_motion_offset);
|
||||
ObjectTypeDB::bind_method(_MD("get_motion_offset"),&ParallaxLayer::get_motion_offset);
|
||||
ObjectTypeDB::bind_method(_MD("set_mirroring","mirror"),&ParallaxLayer::set_mirroring);
|
||||
ObjectTypeDB::bind_method(_MD("get_mirroring"),&ParallaxLayer::get_mirroring);
|
||||
|
||||
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/scale"),_SCS("set_motion_scale"),_SCS("get_motion_scale"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/offset"),_SCS("set_motion_offset"),_SCS("get_motion_offset"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/mirroring"),_SCS("set_mirroring"),_SCS("get_mirroring"));
|
||||
ObjectTypeDB::bind_method(_MD("set_motion_scale", "scale"), &ParallaxLayer::set_motion_scale);
|
||||
ObjectTypeDB::bind_method(_MD("get_motion_scale"), &ParallaxLayer::get_motion_scale);
|
||||
ObjectTypeDB::bind_method(_MD("set_motion_offset", "offset"), &ParallaxLayer::set_motion_offset);
|
||||
ObjectTypeDB::bind_method(_MD("get_motion_offset"), &ParallaxLayer::get_motion_offset);
|
||||
ObjectTypeDB::bind_method(_MD("set_mirroring", "mirror"), &ParallaxLayer::set_mirroring);
|
||||
ObjectTypeDB::bind_method(_MD("get_mirroring"), &ParallaxLayer::get_mirroring);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion/scale"), _SCS("set_motion_scale"), _SCS("get_motion_scale"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion/offset"), _SCS("set_motion_offset"), _SCS("get_motion_offset"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion/mirroring"), _SCS("set_mirroring"), _SCS("get_mirroring"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
ParallaxLayer::ParallaxLayer()
|
||||
{
|
||||
motion_scale=Size2(1,1);
|
||||
ParallaxLayer::ParallaxLayer() {
|
||||
motion_scale = Size2(1, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user