Import brushes from folder

- A new type of custom brush has been added, brushes from files! Basically there's a "Brushes" folder where Pixelorama can get brushes from, and, unlike the previous brushes, these are for all projects and are not saved in .pxo files. These brushes get loaded on the _ready() method of Main.gd, and are ignored by Godot.
- There are now 2 containers for the two types of custom brushes. The main pixel brush is with the brushes from files.
- Fixed bug where, if you had selected a custom "project" brush and loaded a .pxo file, the brush would still be selected, causing potential problems
- Fixed bug where you could save a project brush that was completely transparent
- Fixed bug where, if you named a file, some shortcuts would be activated.
- export_presets.cfg is now ignored.
This commit is contained in:
OverloadedOrama 2019-11-11 04:20:09 +02:00
parent e825cc03e5
commit b1e8bde3ac
10 changed files with 108 additions and 88 deletions

View file

@ -97,22 +97,23 @@ func _process(delta) -> void:
#Handle copy
if Input.is_action_just_pressed("copy") && Global.selected_pixels.size() > 0:
Global.image_clipboard = layer.get_rect(Rect2(polygon[0], polygon[2] - polygon[0]))
#And save as custom brush
var brush_img := Image.new()
brush_img = layer.get_rect(Rect2(polygon[0], polygon[2] - polygon[0]))
if brush_img.is_invisible():
return
brush_img = brush_img.get_rect(brush_img.get_used_rect()) #save only the visible pixels
Global.custom_brushes.append(brush_img)
Global.create_brush_button(brush_img)
Global.image_clipboard = layer.get_rect(Rect2(polygon[0], polygon[2] - polygon[0]))
#Handle paste
if Input.is_action_just_pressed("paste") && Global.selected_pixels.size() > 0 && Global.image_clipboard.get_size() > Vector2.ZERO:
Global.canvas.handle_undo("Draw")
layer.blend_rect(Global.image_clipboard, Rect2(Vector2.ZERO, polygon[2]-polygon[0]), polygon[0])
layer.lock()
Global.canvas.handle_redo("Draw")
#Global.canvas.update_texture(Global.canvas.current_layer_index)
func _draw() -> void:
if img.get_size() == polygon[2] - polygon[0]: