From f882fd2375d146a96202a249eb6c9c133ffdc4da Mon Sep 17 00:00:00 2001 From: Variable Date: Mon, 14 Oct 2024 20:18:45 +0500 Subject: [PATCH] rename _fill to _fill_inside for sync consistency (fill in pencil and shape tools basically represent the same thing) --- src/Autoload/Tools.gd | 6 ++++-- src/Tools/BaseShapeDrawer.gd | 12 ++++++------ src/Tools/DesignTools/CurveTool.gd | 12 ++++++------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/Autoload/Tools.gd b/src/Autoload/Tools.gd index e1bb3fe47..4749ec299 100644 --- a/src/Autoload/Tools.gd +++ b/src/Autoload/Tools.gd @@ -435,7 +435,8 @@ func remove_tool(t: Tool) -> void: func set_tool(tool_name: String, button: int) -> void: ## To prevent any unintentional syncing, we will temporarily disconnect the signal - Tools.config_changed.disconnect(attempt_config_share) + if Tools.config_changed.is_connected(attempt_config_share): + Tools.config_changed.disconnect(attempt_config_share) var slot: Slot = _slots[button] var panel: Node = _panels[button] var node: Node = tools[tool_name].instantiate_scene() @@ -460,7 +461,8 @@ func set_tool(tool_name: String, button: int) -> void: # Wait for config to get loaded, then re-connect and sync await get_tree().process_frame - Tools.config_changed.connect(attempt_config_share) + if not Tools.config_changed.is_connected(attempt_config_share): + Tools.config_changed.connect(attempt_config_share) attempt_config_share(config_slot) # Sync it with the other tool diff --git a/src/Tools/BaseShapeDrawer.gd b/src/Tools/BaseShapeDrawer.gd index 54369d670..9544c7438 100644 --- a/src/Tools/BaseShapeDrawer.gd +++ b/src/Tools/BaseShapeDrawer.gd @@ -3,7 +3,7 @@ extends "res://src/Tools/BaseDraw.gd" var _start := Vector2i.ZERO var _offset := Vector2i.ZERO var _dest := Vector2i.ZERO -var _fill := false +var _fill_inside := false var _drawing := false var _displace_origin := false var _thickness := 1 @@ -41,27 +41,27 @@ func update_indicator() -> void: func _on_FillCheckbox_toggled(button_pressed: bool) -> void: - _fill = button_pressed + _fill_inside = button_pressed update_config() save_config() func get_config() -> Dictionary: var config := super.get_config() - config["fill"] = _fill + config["fill_inside"] = _fill_inside config["thickness"] = _thickness return config func set_config(config: Dictionary) -> void: super.set_config(config) - _fill = config.get("fill", _fill) + _fill_inside = config.get("fill_inside", _fill_inside) _thickness = config.get("thickness", _thickness) func update_config() -> void: super.update_config() - $FillCheckbox.button_pressed = _fill + $FillCheckbox.button_pressed = _fill_inside $ThicknessSlider.value = _thickness @@ -237,7 +237,7 @@ func _get_result_rect(origin: Vector2i, dest: Vector2i) -> Rect2i: func _get_points(shape_size: Vector2i) -> Array[Vector2i]: - return _get_shape_points_filled(shape_size) if _fill else _get_shape_points(shape_size) + return _get_shape_points_filled(shape_size) if _fill_inside else _get_shape_points(shape_size) func _set_cursor_text(rect: Rect2i) -> void: diff --git a/src/Tools/DesignTools/CurveTool.gd b/src/Tools/DesignTools/CurveTool.gd index 803c7efbb..9219c2bbc 100644 --- a/src/Tools/DesignTools/CurveTool.gd +++ b/src/Tools/DesignTools/CurveTool.gd @@ -2,7 +2,7 @@ extends "res://src/Tools/BaseDraw.gd" var _curve := Curve2D.new() ## The [Curve2D] responsible for the shape of the curve being drawn. var _drawing := false ## Set to true when a curve is being drawn. -var _fill := false ## When true, the inside area of the curve gets filled. +var _fill_inside := false ## When true, the inside area of the curve gets filled. var _fill_inside_rect := Rect2i() ## The bounding box that surrounds the area that gets filled. var _editing_bezier := false ## Needed to determine when to show the control points preview line. var _editing_out_control_point := false ## True when controlling the out control point only. @@ -29,7 +29,7 @@ func _on_thickness_value_changed(value: int) -> void: func _on_fill_checkbox_toggled(toggled_on: bool) -> void: - _fill = toggled_on + _fill_inside = toggled_on update_config() save_config() @@ -44,20 +44,20 @@ func update_indicator() -> void: func get_config() -> Dictionary: var config := super.get_config() - config["fill"] = _fill + config["fill_inside"] = _fill_inside config["thickness"] = _thickness return config func set_config(config: Dictionary) -> void: super.set_config(config) - _fill = config.get("fill", _fill) + _fill_inside = config.get("fill_inside", _fill_inside) _thickness = config.get("thickness", _thickness) func update_config() -> void: super.update_config() - $FillCheckbox.button_pressed = _fill + $FillCheckbox.button_pressed = _fill_inside $ThicknessSlider.value = _thickness @@ -191,7 +191,7 @@ func _draw_shape() -> void: _fill_inside_rect = _fill_inside_rect.expand(point) # Draw each point offsetted based on the shape's thickness _draw_pixel(point, images) - if _fill: + if _fill_inside: var v := Vector2i() for x in _fill_inside_rect.size.x: v.x = x + _fill_inside_rect.position.x