Brushes now get removed when opening a project, indicators for chosen sprites

- If you had custom brushes in your project and you opened a new one (from a .pxo file), the brushes would stack. Now, the previous brushes get removed.
- Added arrow left and right indicators for the selected brushes.
This commit is contained in:
OverloadedOrama 2019-10-02 21:58:19 +03:00
parent be6f9121ed
commit eb29cd3268
5 changed files with 66 additions and 43 deletions

View file

@ -6,12 +6,16 @@ var custom_brush_index := -1
func _on_BrushButton_pressed() -> void:
if Input.is_action_just_released("left_mouse"):
Global.current_left_brush_type = brush_type
Global.left_brush_indicator.get_parent().remove_child(Global.left_brush_indicator)
add_child(Global.left_brush_indicator)
if custom_brush_index > -1:
Global.custom_left_brush_index = custom_brush_index
Global.update_left_custom_brush()
elif Input.is_action_just_released("right_mouse"):
Global.current_right_brush_type = brush_type
Global.right_brush_indicator.get_parent().remove_child(Global.right_brush_indicator)
add_child(Global.right_brush_indicator)
if custom_brush_index > -1:
Global.custom_right_brush_index = custom_brush_index
Global.update_right_custom_brush()

View file

@ -216,7 +216,6 @@ func _draw() -> void:
else:
color = Color.white
for i in range(1, Global.onion_skinning_future_rate + 1):
#print(i)
if Global.current_frame < Global.canvases.size() - i:
for texture in Global.canvases[Global.current_frame + i].layers:
color.a = 0.6/i
@ -285,10 +284,8 @@ func generate_layer_panels() -> void:
for i in range(layers.size() -1, -1, -1):
var layer_container = load("res://Prefabs/LayerContainer.tscn").instance()
#layer_names.insert(i, "Layer %s" % i)
layers[i][2] = "Layer %s" % i
layer_container.i = i
#layer_container.get_child(0).get_child(2).text = layer_names[i]
layer_container.get_child(0).get_child(2).text = layers[i][2]
layers[i][3] = true #set visible
layer_container.get_child(0).get_child(1).texture = layers[i][1]

View file

@ -44,7 +44,8 @@ var left_brush_size_edit : SpinBox
var right_brush_size_edit : SpinBox
var left_interpolate_slider : HSlider
var right_interpolate_slider : HSlider
var left_brush_indicator : Sprite
var right_brush_indicator : Sprite
var loop_animation_button : Button
var play_forward : Button
@ -119,6 +120,9 @@ func _ready() -> void:
left_interpolate_slider = find_node_by_name(root, "LeftInterpolateFactor")
right_interpolate_slider = find_node_by_name(root, "RightInterpolateFactor")
left_brush_indicator = find_node_by_name(root, "LeftBrushIndicator")
right_brush_indicator = find_node_by_name(root, "RightBrushIndicator")
loop_animation_button = find_node_by_name(root, "LoopAnim")
play_forward = find_node_by_name(root, "PlayForward")
play_backwards = find_node_by_name(root, "PlayBackwards")
@ -183,7 +187,15 @@ func create_brush_button(brush_img : Image) -> void:
brush_button.get_child(0).texture = brush_tex
var hbox_container := find_node_by_name(get_tree().get_root(), "BrushHBoxContainer")
hbox_container.add_child(brush_button)
func remove_brush_buttons() -> void:
var hbox_container := find_node_by_name(get_tree().get_root(), "BrushHBoxContainer")
for child in hbox_container.get_children():
if child.name != "PixelBrushButton":
hbox_container.remove_child(child)
# for i in range(0, hbox_container.get_child_count() - 1):
# hbox_container.remove_child(hbox_container.get_child(i))
func update_left_custom_brush() -> void:
if custom_left_brush_index > -1:
var custom_brush := Image.new()

View file

@ -283,6 +283,9 @@ func _on_OpenSprite_file_selected(path) -> void:
Global.right_color_picker.get_picker().add_preset(color)
#Load custom brushes
Global.custom_brushes.clear()
Global.remove_brush_buttons()
var brush_line := file.get_line()
while brush_line == "/":
var b_width := file.get_16()