mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-11 05:19:50 +01:00
Changed the prefix of the image saving related helpers from save to render.
This commit is contained in:
parent
fb4aa87663
commit
9141997c87
@ -344,7 +344,7 @@ Ref<ImageTexture> PaintCanvas::get_preview_image_texture() {
|
||||
return _preview_image_texture;
|
||||
}
|
||||
|
||||
Ref<Image> PaintCanvas::_get_save_image() {
|
||||
Ref<Image> PaintCanvas::_get_rendered_image() {
|
||||
return _image;
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
Ref<ImageTexture> get_image_texture();
|
||||
Ref<ImageTexture> get_preview_image_texture();
|
||||
|
||||
Ref<Image> _get_save_image();
|
||||
Ref<Image> _get_rendered_image();
|
||||
|
||||
PoolByteArray get_image_data_compressed();
|
||||
void set_image_data_compressed(const PoolByteArray &arr);
|
||||
|
@ -27,14 +27,14 @@ void PaintNode::set_draw_outline(const bool val) {
|
||||
update();
|
||||
}
|
||||
|
||||
Ref<Image> PaintNode::save_image() {
|
||||
_propagate_notification_project_pre_save();
|
||||
Ref<Image> img = call("_save_image");
|
||||
_propagate_notification_project_post_save();
|
||||
Ref<Image> PaintNode::render_image() {
|
||||
_propagate_notification_project_pre_render();
|
||||
Ref<Image> img = call("_render_image");
|
||||
_propagate_notification_project_post_render();
|
||||
|
||||
return img;
|
||||
}
|
||||
Ref<Image> PaintNode::_save_image() {
|
||||
Ref<Image> PaintNode::_render_image() {
|
||||
Ref<Image> image;
|
||||
image.instance();
|
||||
|
||||
@ -51,23 +51,23 @@ Ref<Image> PaintNode::_save_image() {
|
||||
|
||||
if (pn && pn->is_visible()) {
|
||||
//dont apply own transform
|
||||
save_evaluate_paint_node(pn, Transform2D(), image);
|
||||
render_evaluate_paint_node(pn, Transform2D(), image);
|
||||
}
|
||||
}
|
||||
|
||||
save_paint_node(this, Transform2D(), image);
|
||||
render_paint_node(this, Transform2D(), image);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
Ref<Image> PaintNode::get_save_image() {
|
||||
return call("_get_save_image");
|
||||
Ref<Image> PaintNode::get_rendered_image() {
|
||||
return call("_get_rendered_image");
|
||||
}
|
||||
Ref<Image> PaintNode::_get_save_image() {
|
||||
Ref<Image> PaintNode::_get_rendered_image() {
|
||||
return Ref<Image>();
|
||||
}
|
||||
|
||||
void PaintNode::save_evaluate_paint_node(PaintNode *node, Transform2D transform, Ref<Image> image) {
|
||||
void PaintNode::render_evaluate_paint_node(PaintNode *node, Transform2D transform, Ref<Image> image) {
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_COND(!image.is_valid());
|
||||
|
||||
@ -77,18 +77,18 @@ void PaintNode::save_evaluate_paint_node(PaintNode *node, Transform2D transform,
|
||||
PaintNode *pn = Object::cast_to<PaintNode>(node->get_child(i));
|
||||
|
||||
if (pn && pn->is_visible()) {
|
||||
save_evaluate_paint_node(pn, currtf, image);
|
||||
render_evaluate_paint_node(pn, currtf, image);
|
||||
}
|
||||
}
|
||||
|
||||
save_paint_node(node, currtf, image);
|
||||
render_paint_node(node, currtf, image);
|
||||
}
|
||||
|
||||
void PaintNode::save_paint_node(PaintNode *node, Transform2D transform, Ref<Image> image) {
|
||||
void PaintNode::render_paint_node(PaintNode *node, Transform2D transform, Ref<Image> image) {
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_COND(!image.is_valid());
|
||||
|
||||
Ref<Image> save_image = node->get_save_image();
|
||||
Ref<Image> save_image = node->get_rendered_image();
|
||||
|
||||
if (!save_image.is_valid() || save_image->empty()) {
|
||||
return;
|
||||
@ -217,25 +217,25 @@ void PaintNode::_propagate_notification_resized() {
|
||||
}
|
||||
}
|
||||
|
||||
void PaintNode::_propagate_notification_project_pre_save() {
|
||||
notification(NOTIFICATION_PAINT_PROJECT_PRE_SAVE);
|
||||
void PaintNode::_propagate_notification_project_pre_render() {
|
||||
notification(NOTIFICATION_PAINT_PROJECT_PRE_RENDER);
|
||||
|
||||
for (int i = 0; i < get_child_count(); ++i) {
|
||||
PaintNode *pn = Object::cast_to<PaintNode>(get_child(i));
|
||||
|
||||
if (pn) {
|
||||
pn->_propagate_notification_project_pre_save();
|
||||
pn->_propagate_notification_project_pre_render();
|
||||
}
|
||||
}
|
||||
}
|
||||
void PaintNode::_propagate_notification_project_post_save() {
|
||||
notification(NOTIFICATION_PAINT_PROJECT_POST_SAVE);
|
||||
void PaintNode::_propagate_notification_project_post_render() {
|
||||
notification(NOTIFICATION_PAINT_PROJECT_POST_RENDER);
|
||||
|
||||
for (int i = 0; i < get_child_count(); ++i) {
|
||||
PaintNode *pn = Object::cast_to<PaintNode>(get_child(i));
|
||||
|
||||
if (pn) {
|
||||
pn->_propagate_notification_project_post_save();
|
||||
pn->_propagate_notification_project_post_render();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -282,13 +282,13 @@ void PaintNode::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_draw_outline", "val"), &PaintNode::set_draw_outline);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_outline"), "set_draw_outline", "get_draw_outline");
|
||||
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "r", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_save_image"));
|
||||
ClassDB::bind_method(D_METHOD("save_image"), &PaintNode::save_image);
|
||||
ClassDB::bind_method(D_METHOD("_save_image"), &PaintNode::_save_image);
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "r", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_render_image"));
|
||||
ClassDB::bind_method(D_METHOD("render_image"), &PaintNode::render_image);
|
||||
ClassDB::bind_method(D_METHOD("_render_image"), &PaintNode::_render_image);
|
||||
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "r", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_get_save_image"));
|
||||
ClassDB::bind_method(D_METHOD("get_save_image"), &PaintNode::get_save_image);
|
||||
ClassDB::bind_method(D_METHOD("_get_save_image"), &PaintNode::_get_save_image);
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "r", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "_get_rendered_image"));
|
||||
ClassDB::bind_method(D_METHOD("get_rendered_image"), &PaintNode::get_rendered_image);
|
||||
ClassDB::bind_method(D_METHOD("_get_rendered_image"), &PaintNode::_get_rendered_image);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("util_get_pixels_in_line", "from", "to"), &PaintNode::util_get_pixels_in_line);
|
||||
|
||||
@ -309,6 +309,6 @@ void PaintNode::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("find_parent_paint_node"), &PaintNode::find_parent_paint_node);
|
||||
|
||||
BIND_CONSTANT(NOTIFICATION_PARENT_PAINT_NODE_RESIZED);
|
||||
BIND_CONSTANT(NOTIFICATION_PAINT_PROJECT_PRE_SAVE);
|
||||
BIND_CONSTANT(NOTIFICATION_PAINT_PROJECT_POST_SAVE);
|
||||
BIND_CONSTANT(NOTIFICATION_PAINT_PROJECT_PRE_RENDER);
|
||||
BIND_CONSTANT(NOTIFICATION_PAINT_PROJECT_POST_RENDER);
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ class PaintNode : public Node2D {
|
||||
public:
|
||||
enum {
|
||||
NOTIFICATION_PARENT_PAINT_NODE_RESIZED = 2500,
|
||||
NOTIFICATION_PAINT_PROJECT_PRE_SAVE = 2501,
|
||||
NOTIFICATION_PAINT_PROJECT_POST_SAVE = 2502,
|
||||
NOTIFICATION_PAINT_PROJECT_PRE_RENDER = 2501,
|
||||
NOTIFICATION_PAINT_PROJECT_POST_RENDER = 2502,
|
||||
};
|
||||
|
||||
Vector2i get_size();
|
||||
@ -23,15 +23,14 @@ public:
|
||||
bool get_draw_outline();
|
||||
void set_draw_outline(const bool val);
|
||||
|
||||
//TODO rename to render image, and get rendered image!
|
||||
Ref<Image> save_image();
|
||||
virtual Ref<Image> _save_image();
|
||||
Ref<Image> render_image();
|
||||
virtual Ref<Image> _render_image();
|
||||
|
||||
Ref<Image> get_save_image();
|
||||
virtual Ref<Image> _get_save_image();
|
||||
Ref<Image> get_rendered_image();
|
||||
virtual Ref<Image> _get_rendered_image();
|
||||
|
||||
void save_evaluate_paint_node(PaintNode *node, Transform2D transform, Ref<Image> image);
|
||||
void save_paint_node(PaintNode *node, Transform2D transform, Ref<Image> image);
|
||||
void render_evaluate_paint_node(PaintNode *node, Transform2D transform, Ref<Image> image);
|
||||
void render_paint_node(PaintNode *node, Transform2D transform, Ref<Image> image);
|
||||
|
||||
PoolVector2iArray util_get_pixels_in_line(const Vector2i &from, const Vector2i &to);
|
||||
|
||||
@ -53,8 +52,8 @@ public:
|
||||
String get_configuration_warning() const;
|
||||
|
||||
void _propagate_notification_resized();
|
||||
void _propagate_notification_project_pre_save();
|
||||
void _propagate_notification_project_post_save();
|
||||
void _propagate_notification_project_pre_render();
|
||||
void _propagate_notification_project_post_render();
|
||||
|
||||
PaintNode();
|
||||
~PaintNode();
|
||||
|
@ -68,7 +68,7 @@ void PaintProject::set_colors_as_default() {
|
||||
void PaintProject::save_image_to_file() {
|
||||
ERR_FAIL_COND(_save_file_name.empty());
|
||||
|
||||
Ref<Image> img = save_image();
|
||||
Ref<Image> img = render_image();
|
||||
|
||||
ERR_FAIL_COND(!img.is_valid());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user