mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-05-09 15:21:35 +02:00
Also port the logic of the selection box and visual grid.
This commit is contained in:
parent
cc217b7eea
commit
d3c039be7e
@ -545,8 +545,10 @@ void PaintCanvas::resize(int width, int height) {
|
|||||||
height = 1;
|
height = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_canvas_width(width);
|
Size2 s;
|
||||||
set_canvas_height(height);
|
s.x = _canvas_height * _pixel_size;
|
||||||
|
s.y = _canvas_width * _pixel_size;
|
||||||
|
set_size(s);
|
||||||
|
|
||||||
preview_layer->resize(width, height);
|
preview_layer->resize(width, height);
|
||||||
tool_layer->resize(width, height);
|
tool_layer->resize(width, height);
|
||||||
@ -558,6 +560,8 @@ void PaintCanvas::resize(int width, int height) {
|
|||||||
|
|
||||||
layer->resize(width, height);
|
layer->resize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintCanvas::_notification(int p_what) {
|
void PaintCanvas::_notification(int p_what) {
|
||||||
@ -573,6 +577,12 @@ void PaintCanvas::_notification(int p_what) {
|
|||||||
preview_layer = add_new_layer("Preview");
|
preview_layer = add_new_layer("Preview");
|
||||||
tool_layer = add_new_layer("Tool");
|
tool_layer = add_new_layer("Tool");
|
||||||
|
|
||||||
|
//hack
|
||||||
|
_canvas_width = 0;
|
||||||
|
_canvas_height = 0;
|
||||||
|
|
||||||
|
resize(64, 64);
|
||||||
|
|
||||||
set_process(true);
|
set_process(true);
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_PROCESS: {
|
case NOTIFICATION_PROCESS: {
|
||||||
@ -588,8 +598,8 @@ PaintCanvas::PaintCanvas() {
|
|||||||
big_grid = nullptr;
|
big_grid = nullptr;
|
||||||
|
|
||||||
_pixel_size = 16;
|
_pixel_size = 16;
|
||||||
_canvas_width = 48;
|
_canvas_width = 64;
|
||||||
_canvas_height = 28;
|
_canvas_height = 64;
|
||||||
_grid_size = 16;
|
_grid_size = 16;
|
||||||
_big_grid_size = 10;
|
_big_grid_size = 10;
|
||||||
_can_draw = true;
|
_can_draw = true;
|
||||||
|
@ -30,30 +30,35 @@ void PaintSelectionBox::_process(float delta) {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
void PaintSelectionBox::_draw() {
|
void PaintSelectionBox::_draw() {
|
||||||
/*
|
if (get_size() != Vector2()) {
|
||||||
if not rect_size == Vector2():
|
draw_outline_box(get_size(), Color(0.75, 0.75, 0.75), outline_size);
|
||||||
draw_outline_box(rect_size, Color.gray, outline_size)
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
void PaintSelectionBox::draw_outline_box(const Vector2 &size, const Color &color, const int width) {
|
void PaintSelectionBox::draw_outline_box(const Vector2 &size, const Color &color, const int width) {
|
||||||
/*
|
//Top line
|
||||||
#Top line
|
draw_line(Vector2(0 + 1, 0), Vector2(size.x, 0), color, width);
|
||||||
draw_line(Vector2(0 + 1, 0), Vector2(size.x, 0), color, width)
|
//Left line
|
||||||
#Left line
|
draw_line(Vector2(0 + 1, 0), Vector2(0, size.y), color, width);
|
||||||
draw_line(Vector2(0 + 1, 0), Vector2(0, size.y), color, width)
|
//Bottom line
|
||||||
#Bottom line
|
draw_line(Vector2(0 + 1, size.y), Vector2(size.x, size.y), color, width);
|
||||||
draw_line(Vector2(0 + 1, size.y), Vector2(size.x, size.y), color, width)
|
//Right line
|
||||||
#Right line
|
draw_line(Vector2(size.x, 0), Vector2(size.x, size.y), color, width);
|
||||||
draw_line(Vector2(size.x, 0), Vector2(size.x, size.y), color, width)
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintSelectionBox::PaintSelectionBox() {
|
PaintSelectionBox::PaintSelectionBox() {
|
||||||
////export var outline_size = 3
|
outline_size = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintSelectionBox::~PaintSelectionBox() {
|
PaintSelectionBox::~PaintSelectionBox() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PaintSelectionBox::_notification(int p_what) {
|
||||||
|
switch (p_what) {
|
||||||
|
case NOTIFICATION_DRAW: {
|
||||||
|
_draw();
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PaintSelectionBox::_bind_methods() {
|
void PaintSelectionBox::_bind_methods() {
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,11 @@ public:
|
|||||||
PaintSelectionBox();
|
PaintSelectionBox();
|
||||||
~PaintSelectionBox();
|
~PaintSelectionBox();
|
||||||
|
|
||||||
protected:
|
int outline_size;
|
||||||
static void _bind_methods();
|
|
||||||
|
|
||||||
//export var outline_size = 3
|
protected:
|
||||||
|
void _notification(int p_what);
|
||||||
|
static void _bind_methods();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,31 +25,32 @@ SOFTWARE.
|
|||||||
#include "paint_visual_grid.h"
|
#include "paint_visual_grid.h"
|
||||||
|
|
||||||
void PaintVisualGrid::_draw() {
|
void PaintVisualGrid::_draw() {
|
||||||
/*
|
if (size == 0) {
|
||||||
if size == 0:
|
size = 1;
|
||||||
size = 1
|
}
|
||||||
|
|
||||||
var temp_size = size + zoom
|
float temp_size = size + zoom;
|
||||||
|
|
||||||
var wrap_offset = Vector2(wrapf(offset.x, 0, temp_size), wrapf(offset.y, 0, temp_size))
|
Vector2 wrap_offset = Vector2(Math::wrapf(offset.x, 0, temp_size), Math::wrapf(offset.y, 0, temp_size));
|
||||||
|
|
||||||
var ceil_x = ceil(rect_size.x / temp_size)
|
Size2 rect_size = get_size();
|
||||||
var ceil_y = ceil(rect_size.y / temp_size)
|
|
||||||
|
|
||||||
for i in ceil_y:
|
float ceil_x = Math::ceil(rect_size.x / temp_size);
|
||||||
var start_x = Vector2(0, (i * temp_size) + wrap_offset.y)
|
float ceil_y = Math::ceil(rect_size.y / temp_size);
|
||||||
var end_x = Vector2(rect_size.x, (i * temp_size) + wrap_offset.y)
|
|
||||||
# var end_x = Vector2(int(rect_size.x) + size - int(rect_size.x) % size, (i * temp_size) + wrap_offset.y)
|
|
||||||
draw_line(start_x, end_x, color, 1)
|
|
||||||
|
|
||||||
for i in ceil_x:
|
for (int i = 0; i < ceil_y; ++i) {
|
||||||
var start_y = Vector2((i * temp_size) + wrap_offset.x, 0)
|
Point2 start_x = Vector2(0, (i * temp_size) + wrap_offset.y);
|
||||||
var end_y = Vector2((i * temp_size) + (wrap_offset.x), rect_size.y)
|
Point2 end_x = Vector2(rect_size.x, (i * temp_size) + wrap_offset.y);
|
||||||
# var end_y = Vector2((i * temp_size) + (wrap_offset.x), int(rect_size.y) + size - int(rect_size.y) % size)
|
//var end_x = Vector2(int(rect_size.x) + size - int(rect_size.x) % size, (i * temp_size) + wrap_offset.y);
|
||||||
draw_line(start_y, end_y, color, 1)
|
draw_line(start_x, end_x, color, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < ceil_x; ++i) {
|
||||||
*/
|
Point2 start_y = Vector2((i * temp_size) + wrap_offset.x, 0);
|
||||||
|
Point2 end_y = Vector2((i * temp_size) + (wrap_offset.x), rect_size.y);
|
||||||
|
//var end_y = Vector2((i * temp_size) + (wrap_offset.x), int(rect_size.y) + size - int(rect_size.y) % size);
|
||||||
|
draw_line(start_y, end_y, color, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintVisualGrid::_notification(int p_what) {
|
void PaintVisualGrid::_notification(int p_what) {
|
||||||
@ -62,15 +63,27 @@ void PaintVisualGrid::_notification(int p_what) {
|
|||||||
return
|
return
|
||||||
update()
|
update()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
switch (p_what) {
|
||||||
|
/*
|
||||||
|
case NOTIFICATION_PROCESS: {
|
||||||
|
if (!is_visible_in_tree()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
update();
|
||||||
|
} break;
|
||||||
|
*/
|
||||||
|
case NOTIFICATION_DRAW: {
|
||||||
|
_draw();
|
||||||
|
} break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintVisualGrid::PaintVisualGrid() {
|
PaintVisualGrid::PaintVisualGrid() {
|
||||||
/*
|
color = Color(1, 1, 1);
|
||||||
export var color = Color()
|
size = 16;
|
||||||
export var size:int = 16
|
zoom = 0;
|
||||||
export var zoom = 0
|
|
||||||
export var offset = Vector2(0, 0)
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintVisualGrid::~PaintVisualGrid() {
|
PaintVisualGrid::~PaintVisualGrid() {
|
||||||
|
@ -27,12 +27,6 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "scene/gui/control.h"
|
#include "scene/gui/control.h"
|
||||||
|
|
||||||
#include "core/reference.h"
|
|
||||||
|
|
||||||
class MeshDataResource;
|
|
||||||
class MeshDataInstance;
|
|
||||||
class Texture;
|
|
||||||
|
|
||||||
class PaintVisualGrid : public Control {
|
class PaintVisualGrid : public Control {
|
||||||
GDCLASS(PaintVisualGrid, Control);
|
GDCLASS(PaintVisualGrid, Control);
|
||||||
|
|
||||||
@ -51,13 +45,6 @@ protected:
|
|||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
/*
|
|
||||||
export var color = Color()
|
|
||||||
export var size:int = 16
|
|
||||||
export var zoom = 0
|
|
||||||
export var offset = Vector2(0, 0)
|
|
||||||
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user