mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-24 01:47:20 +01:00
Added new overridable virtual api to PaintActions for commiting changes.
This commit is contained in:
parent
c2e8a32c90
commit
a5c5201aa8
@ -56,7 +56,7 @@ void CutAction::set_mouse_start_pos_set(const bool val) {
|
||||
mouse_start_pos_set = val;
|
||||
}
|
||||
|
||||
bool CutAction::can_commit() {
|
||||
bool CutAction::_can_commit() {
|
||||
return false; //ugly way of handling a cut
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
bool get_mouse_start_pos_set();
|
||||
void set_mouse_start_pos_set(const bool val);
|
||||
|
||||
bool can_commit();
|
||||
bool _can_commit();
|
||||
|
||||
void do_action_old(PaintCanvasOld *canvas, const Array &data);
|
||||
void commit_action_old(PaintCanvasOld *canvas);
|
||||
|
@ -98,7 +98,7 @@ void LineAction::commit_action_old(PaintCanvasOld *canvas) {
|
||||
mouse_start_pos_set = false;
|
||||
}
|
||||
|
||||
bool LineAction::can_commit() {
|
||||
bool LineAction::_can_commit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
|
||||
void do_action_old(PaintCanvasOld *canvas, const Array &data);
|
||||
void commit_action_old(PaintCanvasOld *canvas);
|
||||
bool can_commit();
|
||||
bool _can_commit();
|
||||
|
||||
LineAction();
|
||||
~LineAction();
|
||||
|
@ -28,7 +28,7 @@ SOFTWARE.
|
||||
#include "../deprecated/paint_canvas_layer.h"
|
||||
#include "../paint_utilities.h"
|
||||
|
||||
bool MultiLineAction::can_commit() {
|
||||
bool MultiLineAction::_can_commit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class MultiLineAction : public PaintAction {
|
||||
GDCLASS(MultiLineAction, PaintAction);
|
||||
|
||||
public:
|
||||
bool can_commit();
|
||||
bool _can_commit();
|
||||
|
||||
void do_action_old(PaintCanvasOld *canvas, const Array &data);
|
||||
//void commit_action_old(PaintCanvasOld *canvas);
|
||||
|
@ -28,6 +28,18 @@ SOFTWARE.
|
||||
#include "../deprecated/paint_canvas_layer.h"
|
||||
#include "core/object/object.h"
|
||||
|
||||
#include "../nodes/paint_canvas.h"
|
||||
|
||||
PaintCanvas *PaintAction::get_canvas() {
|
||||
return _canvas;
|
||||
}
|
||||
void PaintAction::set_canvas(PaintCanvas *canvas) {
|
||||
_canvas = canvas;
|
||||
}
|
||||
void PaintAction::set_canvas_bind(Node *canvas) {
|
||||
set_canvas(Object::cast_to<PaintCanvas>(canvas));
|
||||
}
|
||||
|
||||
Dictionary PaintAction::get_action_data_undo() {
|
||||
return action_data_undo;
|
||||
}
|
||||
@ -123,6 +135,10 @@ void PaintAction::redo_action_old(PaintCanvasOld *canvas) {
|
||||
}
|
||||
|
||||
bool PaintAction::can_commit() {
|
||||
return call("_can_commit");
|
||||
}
|
||||
|
||||
bool PaintAction::_can_commit() {
|
||||
return !redo_cells.empty();
|
||||
}
|
||||
|
||||
@ -259,6 +275,30 @@ void PaintAction::draw_points(PaintCanvasOld *canvas, const PoolVector2iArray &p
|
||||
}
|
||||
}
|
||||
|
||||
void PaintAction::do_action(const Array &data) {
|
||||
call("_do_action", data);
|
||||
}
|
||||
void PaintAction::commit_action() {
|
||||
call("_commit_action");
|
||||
}
|
||||
|
||||
void PaintAction::undo_action() {
|
||||
call("_undo_action");
|
||||
}
|
||||
void PaintAction::redo_action() {
|
||||
call("_redo_action");
|
||||
}
|
||||
|
||||
void PaintAction::_do_action(const Array &data) {
|
||||
}
|
||||
void PaintAction::_commit_action() {
|
||||
}
|
||||
|
||||
void PaintAction::_undo_action() {
|
||||
}
|
||||
void PaintAction::_redo_action() {
|
||||
}
|
||||
|
||||
PaintAction::PaintAction() {
|
||||
}
|
||||
|
||||
@ -302,11 +342,26 @@ void PaintAction::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_preview_colors", "value"), &PaintAction::set_preview_colors);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_COLOR_ARRAY, "preview_colors"), "set_preview_colors", "get_preview_colors");
|
||||
|
||||
//ClassDB::bind_method(D_METHOD("get_layer"), &PaintAction::get_layer);
|
||||
//ClassDB::bind_method(D_METHOD("set_layer", "value"), &PaintAction::set_layer);
|
||||
//ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "layer", PROPERTY_HINT_RESOURCE_TYPE, "PaintCanvasLayer", 0), "set_layer", "get_layer");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_action_data"), &PaintAction::get_action_data);
|
||||
ClassDB::bind_method(D_METHOD("set_action_data", "value"), &PaintAction::set_action_data);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "action_data"), "set_action_data", "get_action_data");
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_do_action", PropertyInfo(Variant::ARRAY, "data")));
|
||||
BIND_VMETHOD(MethodInfo("_commit_action"));
|
||||
BIND_VMETHOD(MethodInfo("_undo_action"));
|
||||
BIND_VMETHOD(MethodInfo("_redo_action"));
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "ret"), "_can_commit"));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("do_action", "data"), &PaintAction::do_action);
|
||||
ClassDB::bind_method(D_METHOD("commit_action"), &PaintAction::commit_action);
|
||||
ClassDB::bind_method(D_METHOD("undo_action"), &PaintAction::undo_action);
|
||||
ClassDB::bind_method(D_METHOD("redo_action"), &PaintAction::redo_action);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_do_action", "data"), &PaintAction::do_action);
|
||||
ClassDB::bind_method(D_METHOD("_commit_action"), &PaintAction::commit_action);
|
||||
ClassDB::bind_method(D_METHOD("_undo_action"), &PaintAction::undo_action);
|
||||
ClassDB::bind_method(D_METHOD("_redo_action"), &PaintAction::redo_action);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("can_commit"), &PaintAction::get_action_data);
|
||||
ClassDB::bind_method(D_METHOD("_can_commit"), &PaintAction::get_action_data);
|
||||
}
|
||||
|
@ -34,12 +34,18 @@ SOFTWARE.
|
||||
#include "core/variant/variant.h"
|
||||
|
||||
class PaintCanvasOld;
|
||||
class PaintCanvas;
|
||||
class PaintCanvasLayer;
|
||||
class Node;
|
||||
|
||||
class PaintAction : public Resource {
|
||||
GDCLASS(PaintAction, Resource);
|
||||
|
||||
public:
|
||||
PaintCanvas *get_canvas();
|
||||
void set_canvas(PaintCanvas *canvas);
|
||||
void set_canvas_bind(Node *canvas);
|
||||
|
||||
Dictionary get_action_data_undo();
|
||||
void set_action_data_undo(const Dictionary &val);
|
||||
|
||||
@ -67,6 +73,7 @@ public:
|
||||
PoolColorArray get_preview_colors();
|
||||
void set_preview_colors(const PoolColorArray &val);
|
||||
|
||||
//deprecated
|
||||
Ref<PaintCanvasLayer> get_layer();
|
||||
void set_layer(const Ref<PaintCanvasLayer> &val);
|
||||
|
||||
@ -79,7 +86,20 @@ public:
|
||||
virtual void undo_action_old(PaintCanvasOld *canvas);
|
||||
virtual void redo_action_old(PaintCanvasOld *canvas);
|
||||
|
||||
virtual bool can_commit();
|
||||
void do_action(const Array &data);
|
||||
void commit_action();
|
||||
|
||||
void undo_action();
|
||||
void redo_action();
|
||||
|
||||
virtual void _do_action(const Array &data);
|
||||
virtual void _commit_action();
|
||||
|
||||
virtual void _undo_action();
|
||||
virtual void _redo_action();
|
||||
|
||||
bool can_commit();
|
||||
virtual bool _can_commit();
|
||||
|
||||
virtual PoolVector2iArray get_x_sym_points(const int canvas_width, const Vector2i &pixel);
|
||||
virtual PoolVector2iArray get_y_sym_points(const int canvas_height, const Vector2i &pixel);
|
||||
@ -110,6 +130,8 @@ public:
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
PaintCanvas *_canvas;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -105,7 +105,7 @@ void RectAction::commit_action_old(PaintCanvasOld *canvas) {
|
||||
mouse_start_pos_set = false;
|
||||
}
|
||||
|
||||
bool RectAction::can_commit() {
|
||||
bool RectAction::_can_commit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
|
||||
void do_action_old(PaintCanvasOld *canvas, const Array &data);
|
||||
void commit_action_old(PaintCanvasOld *canvas);
|
||||
bool can_commit();
|
||||
bool _can_commit();
|
||||
|
||||
RectAction();
|
||||
~RectAction();
|
||||
|
Loading…
Reference in New Issue
Block a user