diff --git a/Main.tscn b/Main.tscn index 32a2ee2f4..fe81815b5 100644 --- a/Main.tscn +++ b/Main.tscn @@ -281,22 +281,6 @@ mouse_default_cursor_shape = 2 button_mask = 3 texture_normal = ExtResource( 6 ) -[node name="ColorToolsContainer" type="HBoxContainer" parent="MenuAndUI/UI/ToolPanel/Tools/MenusAndTools"] -visible = false -margin_top = 142.0 -margin_right = 226.0 -margin_bottom = 162.0 - -[node name="PaintAllPixelsSameColor" type="Button" parent="MenuAndUI/UI/ToolPanel/Tools/MenusAndTools/ColorToolsContainer"] -margin_right = 112.0 -margin_bottom = 20.0 -hint_tooltip = "Paint all pixels of the same color -A for left mouse button -Alt + A for right mouse button" -mouse_default_cursor_shape = 2 -button_mask = 3 -text = "PaintSameColor" - [node name="ToolOptions" type="VBoxContainer" parent="MenuAndUI/UI/ToolPanel/Tools"] margin_top = 157.0 margin_right = 226.0 diff --git a/Scripts/Global.gd b/Scripts/Global.gd index 1cd058f0a..d4f4fc419 100644 --- a/Scripts/Global.gd +++ b/Scripts/Global.gd @@ -48,19 +48,33 @@ var file_menu : MenuButton var edit_menu : MenuButton var view_menu : MenuButton var help_menu : MenuButton + var left_color_picker : ColorPickerButton var right_color_picker : ColorPickerButton + +var left_tool_options_container : Container +var right_tool_options_container : Container + +var left_brush_type_container : Container +var right_brush_type_container : Container var left_brush_type_button : BaseButton var right_brush_type_button : BaseButton var left_brush_type_label : Label var right_brush_type_label : Label + +var left_brush_size_container : Container +var right_brush_size_container : Container var left_brush_size_edit : SpinBox var right_brush_size_edit : SpinBox + var left_color_interpolation_container : Container var right_color_interpolation_container : Container var left_interpolate_slider : HSlider var right_interpolate_slider : HSlider +var left_mirror_container : Container +var right_mirror_container : Container + var loop_animation_button : BaseButton var play_forward : BaseButton var play_backwards : BaseButton @@ -139,18 +153,32 @@ func _ready() -> void: edit_menu = find_node_by_name(root, "EditMenu") view_menu = find_node_by_name(root, "ViewMenu") help_menu = find_node_by_name(root, "HelpMenu") + + left_tool_options_container = find_node_by_name(root, "LeftToolOptions") + right_tool_options_container = find_node_by_name(root, "RightToolOptions") + left_color_picker = find_node_by_name(root, "LeftColorPickerButton") right_color_picker = find_node_by_name(root, "RightColorPickerButton") - left_brush_type_button = find_node_by_name(root, "LeftBrushTypeButton") - right_brush_type_button = find_node_by_name(root, "RightBrushTypeButton") - left_brush_type_label = find_node_by_name(root, "LeftBrushTypeLabel") - right_brush_type_label = find_node_by_name(root, "RightBrushTypeLabel") - left_brush_size_edit = find_node_by_name(root, "LeftBrushSizeEdit") - right_brush_size_edit = find_node_by_name(root, "RightBrushSizeEdit") - left_color_interpolation_container = find_node_by_name(root, "LeftColorInterpolation") - right_color_interpolation_container = find_node_by_name(root, "RightColorInterpolation") - left_interpolate_slider = find_node_by_name(root, "LeftInterpolateFactor") - right_interpolate_slider = find_node_by_name(root, "RightInterpolateFactor") + + left_brush_type_container = find_node_by_name(left_tool_options_container, "LeftBrushType") + right_brush_type_container = find_node_by_name(right_tool_options_container, "RightBrushType") + left_brush_type_button = find_node_by_name(left_brush_type_container, "LeftBrushTypeButton") + right_brush_type_button = find_node_by_name(right_brush_type_container, "RightBrushTypeButton") + left_brush_type_label = find_node_by_name(left_brush_type_container, "LeftBrushTypeLabel") + right_brush_type_label = find_node_by_name(right_brush_type_container, "RightBrushTypeLabel") + + left_brush_size_container = find_node_by_name(left_tool_options_container, "LeftBrushSize") + right_brush_size_container = find_node_by_name(right_tool_options_container, "RightBrushSize") + left_brush_size_edit = find_node_by_name(left_brush_size_container, "LeftBrushSizeEdit") + right_brush_size_edit = find_node_by_name(right_brush_size_container, "RightBrushSizeEdit") + + left_color_interpolation_container = find_node_by_name(left_tool_options_container, "LeftColorInterpolation") + right_color_interpolation_container = find_node_by_name(right_tool_options_container, "RightColorInterpolation") + left_interpolate_slider = find_node_by_name(left_color_interpolation_container, "LeftInterpolateFactor") + right_interpolate_slider = find_node_by_name(right_color_interpolation_container, "RightInterpolateFactor") + + left_mirror_container = find_node_by_name(left_tool_options_container, "LeftMirroring") + right_mirror_container = find_node_by_name(right_tool_options_container, "RightMirroring") loop_animation_button = find_node_by_name(root, "LoopAnim") play_forward = find_node_by_name(root, "PlayForward") diff --git a/Scripts/Main.gd b/Scripts/Main.gd index 7ae760f90..5eb8dc92e 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -98,7 +98,6 @@ func _ready() -> void: tools.append([Global.find_node_by_name(root, "Pencil"), "left_pencil_tool", "right_pencil_tool"]) tools.append([Global.find_node_by_name(root, "Eraser"), "left_eraser_tool", "right_eraser_tool"]) tools.append([Global.find_node_by_name(root, "Bucket"), "left_fill_tool", "right_fill_tool"]) - tools.append([Global.find_node_by_name(root, "PaintAllPixelsSameColor"), "left_paint_all_tool", "right_paint_all_tool"]) tools.append([Global.find_node_by_name(root, "LightenDarken"), "left_lightdark_tool", "right_lightdark_tool"]) tools.append([Global.find_node_by_name(root, "RectSelect"), "left_rectangle_select_tool", "right_rectangle_select_tool"]) @@ -598,13 +597,53 @@ func _on_Tool_pressed(tool_pressed : BaseButton, mouse_press := true, key_for_le var current_action := tool_pressed.name if (mouse_press && Input.is_action_just_released("left_mouse")) || (!mouse_press && key_for_left): Global.current_left_tool = current_action + + #Start from 2, so the label and the cursor checkbox won't get invisible + for i in range(2, Global.left_tool_options_container.get_child_count()): + Global.left_tool_options_container.get_child(i).visible = false + + #Tool options visible depending on the selected tool + if current_action == "Pencil": + Global.left_brush_type_container.visible = true + Global.left_brush_size_container.visible = true + Global.left_mirror_container.visible = true + if Global.current_left_brush_type != Global.BRUSH_TYPES.PIXEL: + Global.left_color_interpolation_container.visible = true + elif current_action == "Eraser": + Global.left_brush_type_container.visible = true + Global.left_brush_size_container.visible = true + Global.left_mirror_container.visible = true + elif current_action == "Bucket": + Global.left_mirror_container.visible = true + elif current_action == "LightenDarken": + Global.left_brush_size_container.visible = true + Global.left_mirror_container.visible = true + elif (mouse_press && Input.is_action_just_released("right_mouse")) || (!mouse_press && !key_for_left): Global.current_right_tool = current_action + #Start from 2, so the label and the cursor checkbox won't get invisible + for i in range(2, Global.right_tool_options_container.get_child_count()): + Global.right_tool_options_container.get_child(i).visible = false + + #Tool options visible depending on the selected tool + if current_action == "Pencil": + Global.right_brush_type_container.visible = true + Global.right_brush_size_container.visible = true + Global.right_mirror_container.visible = true + if Global.current_right_brush_type != Global.BRUSH_TYPES.PIXEL: + Global.right_color_interpolation_container.visible = true + elif current_action == "Eraser": + Global.right_brush_type_container.visible = true + Global.right_brush_size_container.visible = true + Global.right_mirror_container.visible = true + elif current_action == "Bucket": + Global.right_mirror_container.visible = true + elif current_action == "LightenDarken": + Global.right_brush_size_container.visible = true + Global.right_mirror_container.visible = true for t in tools: var tool_name : String = t[0].name - if tool_name == "PaintAllPixelsSameColor": - continue if tool_name == Global.current_left_tool && tool_name == Global.current_right_tool: t[0].texture_normal = load("res://Assets/Graphics/Tools/%s_l_r.png" % tool_name) elif tool_name == Global.current_left_tool: