1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

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

@ -17,7 +17,6 @@ anchor_bottom = 1.0
script = ExtResource( 1 )
[node name="UI" type="HBoxContainer" parent="."]
editor/display_folded = true
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
@ -36,12 +35,12 @@ size_flags_horizontal = 3
size_flags_vertical = 3
[node name="MenusAndTools" type="VBoxContainer" parent="UI/ToolPanel/Tools"]
margin_right = 328.0
margin_right = 320.0
margin_bottom = 266.0
size_flags_vertical = 3
[node name="MenuItems" type="HBoxContainer" parent="UI/ToolPanel/Tools/MenusAndTools"]
margin_right = 328.0
margin_right = 320.0
margin_bottom = 20.0
[node name="FileMenu" type="MenuButton" parent="UI/ToolPanel/Tools/MenusAndTools/MenuItems"]
@ -76,13 +75,11 @@ theme = ExtResource( 2 )
text = "Help"
[node name="ToolsContainer" type="HBoxContainer" parent="UI/ToolPanel/Tools/MenusAndTools"]
editor/display_folded = true
margin_top = 24.0
margin_right = 328.0
margin_right = 320.0
margin_bottom = 44.0
[node name="Pencil" type="Button" parent="UI/ToolPanel/Tools/MenusAndTools/ToolsContainer"]
editor/display_folded = true
margin_right = 51.0
margin_bottom = 20.0
hint_tooltip = "P for left mouse button
@ -98,7 +95,6 @@ centered = false
offset = Vector2( 0, -10 )
[node name="Eraser" type="Button" parent="UI/ToolPanel/Tools/MenusAndTools/ToolsContainer"]
editor/display_folded = true
margin_left = 55.0
margin_right = 106.0
margin_bottom = 20.0
@ -137,28 +133,28 @@ text = "RectSelect"
[node name="HSeparator" type="HSeparator" parent="UI/ToolPanel/Tools"]
margin_top = 270.0
margin_right = 328.0
margin_right = 320.0
margin_bottom = 274.0
[node name="ToolOptions" type="HBoxContainer" parent="UI/ToolPanel/Tools"]
margin_top = 278.0
margin_right = 328.0
margin_right = 320.0
margin_bottom = 544.0
size_flags_vertical = 3
[node name="LeftToolOptions" type="VBoxContainer" parent="UI/ToolPanel/Tools/ToolOptions"]
margin_right = 158.0
margin_right = 154.0
margin_bottom = 266.0
size_flags_horizontal = 3
[node name="LeftLabel" type="Label" parent="UI/ToolPanel/Tools/ToolOptions/LeftToolOptions"]
margin_right = 158.0
margin_right = 154.0
margin_bottom = 14.0
text = "Left tool options"
[node name="LeftIndicatorCheckbox" type="CheckBox" parent="UI/ToolPanel/Tools/ToolOptions/LeftToolOptions"]
margin_top = 18.0
margin_right = 158.0
margin_right = 154.0
margin_bottom = 42.0
mouse_default_cursor_shape = 2
pressed = true
@ -166,9 +162,9 @@ text = "Show left indicator"
[node name="LeftColorPickerButton" type="ColorPickerButton" parent="UI/ToolPanel/Tools/ToolOptions/LeftToolOptions"]
margin_top = 46.0
margin_right = 32.0
margin_right = 36.0
margin_bottom = 78.0
rect_min_size = Vector2( 32, 32 )
rect_min_size = Vector2( 36, 32 )
hint_tooltip = "Color picker for the left tool"
mouse_default_cursor_shape = 2
size_flags_horizontal = 0
@ -176,7 +172,7 @@ size_flags_vertical = 0
[node name="BrushSize" type="HBoxContainer" parent="UI/ToolPanel/Tools/ToolOptions/LeftToolOptions"]
margin_top = 82.0
margin_right = 158.0
margin_right = 154.0
margin_bottom = 106.0
[node name="BrushSizeLabel" type="Label" parent="UI/ToolPanel/Tools/ToolOptions/LeftToolOptions/BrushSize"]
@ -196,13 +192,13 @@ suffix = "px"
[node name="ColorComesFrom" type="Label" parent="UI/ToolPanel/Tools/ToolOptions/LeftToolOptions"]
margin_top = 110.0
margin_right = 158.0
margin_right = 154.0
margin_bottom = 124.0
text = "Brush's color from"
[node name="InterpolateColor" type="HBoxContainer" parent="UI/ToolPanel/Tools/ToolOptions/LeftToolOptions"]
margin_top = 128.0
margin_right = 158.0
margin_right = 154.0
margin_bottom = 144.0
[node name="BrushColorLabel" type="Label" parent="UI/ToolPanel/Tools/ToolOptions/LeftToolOptions/InterpolateColor"]
@ -214,7 +210,7 @@ text = "Brush"
[node name="LeftInterpolateFactor" type="HSlider" parent="UI/ToolPanel/Tools/ToolOptions/LeftToolOptions/InterpolateColor"]
margin_left = 41.0
margin_right = 121.0
margin_right = 117.0
margin_bottom = 16.0
size_flags_horizontal = 3
max_value = 1.0
@ -223,41 +219,42 @@ value = 0.5
ticks_on_borders = true
[node name="SelectedColorLabel" type="Label" parent="UI/ToolPanel/Tools/ToolOptions/LeftToolOptions/InterpolateColor"]
margin_left = 125.0
margin_left = 121.0
margin_top = 1.0
margin_right = 158.0
margin_right = 154.0
margin_bottom = 15.0
rect_pivot_offset = Vector2( -90, -47 )
text = "Color"
[node name="VSeparator" type="VSeparator" parent="UI/ToolPanel/Tools/ToolOptions"]
margin_left = 162.0
margin_right = 166.0
margin_left = 158.0
margin_right = 162.0
margin_bottom = 266.0
[node name="RightToolOptions" type="VBoxContainer" parent="UI/ToolPanel/Tools/ToolOptions"]
margin_left = 170.0
margin_right = 328.0
editor/display_folded = true
margin_left = 166.0
margin_right = 320.0
margin_bottom = 266.0
size_flags_horizontal = 3
[node name="RightLabel" type="Label" parent="UI/ToolPanel/Tools/ToolOptions/RightToolOptions"]
margin_right = 158.0
margin_right = 154.0
margin_bottom = 14.0
text = "Right tool options"
[node name="RightIndicatorCheckbox" type="CheckBox" parent="UI/ToolPanel/Tools/ToolOptions/RightToolOptions"]
margin_top = 18.0
margin_right = 158.0
margin_right = 154.0
margin_bottom = 42.0
mouse_default_cursor_shape = 2
text = "Show right indicator"
[node name="RightColorPickerButton" type="ColorPickerButton" parent="UI/ToolPanel/Tools/ToolOptions/RightToolOptions"]
margin_top = 46.0
margin_right = 32.0
margin_right = 36.0
margin_bottom = 78.0
rect_min_size = Vector2( 32, 32 )
rect_min_size = Vector2( 36, 32 )
hint_tooltip = "Color picker for the right tool"
mouse_default_cursor_shape = 2
size_flags_horizontal = 0
@ -265,7 +262,7 @@ size_flags_vertical = 0
[node name="BrushSize" type="HBoxContainer" parent="UI/ToolPanel/Tools/ToolOptions/RightToolOptions"]
margin_top = 82.0
margin_right = 158.0
margin_right = 154.0
margin_bottom = 106.0
[node name="BrushSizeLabel" type="Label" parent="UI/ToolPanel/Tools/ToolOptions/RightToolOptions/BrushSize"]
@ -285,13 +282,13 @@ suffix = "px"
[node name="ColorComesFrom" type="Label" parent="UI/ToolPanel/Tools/ToolOptions/RightToolOptions"]
margin_top = 110.0
margin_right = 158.0
margin_right = 154.0
margin_bottom = 124.0
text = "Brush's color from"
[node name="InterpolateColor" type="HBoxContainer" parent="UI/ToolPanel/Tools/ToolOptions/RightToolOptions"]
margin_top = 128.0
margin_right = 158.0
margin_right = 154.0
margin_bottom = 144.0
[node name="BrushColorLabel" type="Label" parent="UI/ToolPanel/Tools/ToolOptions/RightToolOptions/InterpolateColor"]
@ -303,7 +300,7 @@ text = "Brush"
[node name="RightInterpolateFactor" type="HSlider" parent="UI/ToolPanel/Tools/ToolOptions/RightToolOptions/InterpolateColor"]
margin_left = 41.0
margin_right = 121.0
margin_right = 117.0
margin_bottom = 16.0
size_flags_horizontal = 3
max_value = 1.0
@ -312,22 +309,21 @@ value = 0.5
ticks_on_borders = true
[node name="SelectedColorLabel" type="Label" parent="UI/ToolPanel/Tools/ToolOptions/RightToolOptions/InterpolateColor"]
margin_left = 125.0
margin_left = 121.0
margin_top = 1.0
margin_right = 158.0
margin_right = 154.0
margin_bottom = 15.0
rect_pivot_offset = Vector2( -90, -47 )
text = "Color"
[node name="HSeparator2" type="HSeparator" parent="UI/ToolPanel/Tools"]
margin_top = 548.0
margin_right = 328.0
margin_right = 320.0
margin_bottom = 552.0
[node name="BrushesContainer" type="ScrollContainer" parent="UI/ToolPanel/Tools"]
editor/display_folded = true
margin_top = 556.0
margin_right = 328.0
margin_right = 320.0
margin_bottom = 592.0
size_flags_horizontal = 3
scroll_vertical_enabled = false
@ -338,9 +334,20 @@ margin_bottom = 36.0
[node name="PixelBrushButton" parent="UI/ToolPanel/Tools/BrushesContainer/BrushHBoxContainer" instance=ExtResource( 5 )]
[node name="LeftBrushIndicator" type="Sprite" parent="UI/ToolPanel/Tools/BrushesContainer/BrushHBoxContainer/PixelBrushButton"]
scale = Vector2( 0.8, 0.8 )
texture = ExtResource( 3 )
centered = false
[node name="RightBrushIndicator" type="Sprite" parent="UI/ToolPanel/Tools/BrushesContainer/BrushHBoxContainer/PixelBrushButton"]
scale = Vector2( 0.8, 0.8 )
texture = ExtResource( 4 )
centered = false
offset = Vector2( 28, 0 )
[node name="HSeparator3" type="HSeparator" parent="UI/ToolPanel/Tools"]
margin_top = 596.0
margin_right = 328.0
margin_right = 320.0
margin_bottom = 600.0
[node name="CanvasAndTimeline" type="VBoxContainer" parent="UI"]

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()