Implemented more tools.

This commit is contained in:
Relintai 2022-11-18 01:26:33 +01:00
parent d8045e273c
commit 3f4d2fa840
2 changed files with 79 additions and 4 deletions

View File

@ -95,6 +95,24 @@ func get_action() -> PaintAction:
if current_tool == TOOL_PENCIL:
action = PencilAction.new()
elif current_tool == TOOL_BRUSH:
action = BrushAction.new()
elif current_tool == TOOL_LINE:
action = LineAction.new()
elif current_tool == TOOL_RAINBOW:
action = RainbowAction.new()
elif current_tool == TOOL_BUCKET:
action = BucketAction.new()
elif current_tool == TOOL_RECT:
action = RectAction.new()
elif current_tool == TOOL_DARKEN:
action = DarkenAction.new()
elif current_tool == TOOL_BRIGHTEN:
action = BrightenAction.new()
elif current_tool == TOOL_CUT:
action = CutAction.new()
elif current_tool == TOOL_PASTECUT:
action = PasteCutAction.new()
if action:
action.paint_canvas = self
@ -116,14 +134,70 @@ func tool_process(local_position : Vector2, event: InputEvent) -> void:
if !_current_action:
_current_action = get_action()
if current_tool == TOOL_PENCIL:
if current_tool == TOOL_PENCIL || current_tool == TOOL_LINE || \
current_tool == TOOL_RECT || current_tool == TOOL_DARKEN || \
current_tool == TOOL_BRIGHTEN || current_tool == TOOL_LINE:
var arr : Array = Array()
arr.push_back(cell_mouse_position)
arr.push_back(last_cell_mouse_position)
arr.push_back(get_current_color())
do_action(arr)
elif current_tool == TOOL_BRUSH:
var arr : Array = Array()
arr.push_back(cell_mouse_position)
arr.push_back(last_cell_mouse_position)
arr.push_back(get_current_color())
arr.push_back(brush_prefab)
arr.push_back(brush_size)
do_action(arr)
elif current_tool == TOOL_COLORPICKER:
pass
elif current_tool == TOOL_PASTECUT:
# Array arr;
#
# arr.append(cell_mouse_position);
# arr.append(last_cell_mouse_position);
# arr.append(_selection_cells);
# arr.append(_selection_colors);
# arr.append(_cut_pos);
# arr.append(_cut_size);
#
# do_action_old(arr);
pass
elif current_tool == TOOL_RAINBOW:
var arr : Array = Array()
arr.push_back(cell_mouse_position)
arr.push_back(last_cell_mouse_position)
do_action(arr)
#RIGHTCLICK
# case Tools::PAINT: {
# Array arr;
#
# arr.append(cell_mouse_position);
# arr.append(last_cell_mouse_position);
# arr.append(Color(1, 1, 1, 0));
#
# do_action_old(arr);
# } break;
# case Tools::BRUSH: {
# Array arr;
#
# arr.append(cell_mouse_position);
# arr.append(last_cell_mouse_position);
# arr.append(Color(1, 1, 1, 0));
# arr.append(selected_brush_prefab);
# arr.append(brush_size_slider->get_value());
#
# do_action_old(arr);
func _forward_canvas_gui_input(event: InputEvent) -> bool:
if event is InputEventMouseButton:

View File

@ -28,7 +28,7 @@ size = Vector2( 32, 32 )
[node name="PaintProject" type="PaintProject"]
size = Vector2i( 128, 128 )
current_color = Color( 0.00784314, 0.835294, 0.564706, 1 )
current_color = Color( 0.964706, 0.992157, 0.121569, 1 )
color_presets = PoolColorArray( 0.67914, 0.117493, 0.0852439, 1, 0.129412, 0.113725, 0.384314, 1, 0.0666667, 0.796078, 0.196078, 1, 0.0666667, 0.796078, 0.196078, 1, 0.964706, 0.992157, 0.121569, 1, 0.00784314, 0.835294, 0.564706, 1, 0.0666667, 0.796078, 0.196078, 1, 0.658824, 0.313726, 0.207843, 1 )
script = ExtResource( 2 )
@ -48,5 +48,6 @@ script = ExtResource( 3 )
[node name="PaintCanvas" type="PaintCanvas" parent="."]
size = Vector2i( 128, 128 )
brush_size = 12
brush_prefab = 3
brush_size = 19
script = ExtResource( 1 )