Added get_paint_project helper method to PaintNode.

This commit is contained in:
Relintai 2022-11-15 23:11:55 +01:00
parent 4851144a55
commit 4a93e21660
2 changed files with 22 additions and 0 deletions

View File

@ -1,5 +1,7 @@
#include "paint_node.h"
#include "paint_project.h"
Vector2i PaintNode::get_size() {
return _size;
}
@ -7,6 +9,22 @@ void PaintNode::set_size(const Vector2i &size) {
_size = size;
}
PaintProject *PaintNode::get_paint_project() {
PaintNode *p = this;
while (p) {
PaintProject *pp = Object::cast_to<PaintProject>(p);
if (pp) {
return pp;
}
p = Object::cast_to<PaintNode>(p->get_parent());
}
return NULL;
}
PaintNode::PaintNode() {
}

View File

@ -5,6 +5,8 @@
#include "scene/2d/node_2d.h"
class PaintProject;
class PaintNode : public Node2D {
GDCLASS(PaintNode, Node2D);
@ -12,6 +14,8 @@ public:
Vector2i get_size();
void set_size(const Vector2i &size);
PaintProject *get_paint_project();
PaintNode();
~PaintNode();