mirror of
https://github.com/Relintai/draw_gd.git
synced 2025-03-13 16:38:51 +01:00
Tools in no longer an autoload.
This commit is contained in:
parent
1cc49621d3
commit
6219747c16
@ -123,7 +123,6 @@ driver="Dummy"
|
||||
|
||||
DrawGD="*res://src/Autoload/Global.gd"
|
||||
OpenSave="*res://src/Autoload/OpenSave.gd"
|
||||
Tools="*res://src/Autoload/Tools.gd"
|
||||
|
||||
[debug]
|
||||
|
||||
|
@ -166,6 +166,9 @@ var quit_and_save_dialog : ConfirmationDialog
|
||||
|
||||
onready var current_version : String = ProjectSettings.get_setting("application/config/Version")
|
||||
|
||||
var tools_script = preload("res://src/Autoload/Tools.gd")
|
||||
var tools = null
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
randomize()
|
||||
@ -173,6 +176,9 @@ func _ready() -> void:
|
||||
root_directory = OS.get_executable_path().get_base_dir()
|
||||
# Load settings from the config file
|
||||
config_cache.load("user://cache.ini")
|
||||
|
||||
tools = tools_script.new()
|
||||
add_child(tools)
|
||||
|
||||
# The fact that root_dir is set earlier than this is important
|
||||
# XDGDataDirs depends on it nyaa
|
||||
|
@ -28,8 +28,8 @@ func open(palette : String) -> void:
|
||||
self.popup_centered()
|
||||
DrawGD.dialog_open(true)
|
||||
|
||||
left_color_button.modulate = Tools.get_assigned_color(BUTTON_LEFT)
|
||||
right_color_button.modulate = Tools.get_assigned_color(BUTTON_RIGHT)
|
||||
left_color_button.modulate = DrawGD.tools.get_assigned_color(BUTTON_LEFT)
|
||||
right_color_button.modulate = DrawGD.tools.get_assigned_color(BUTTON_RIGHT)
|
||||
|
||||
|
||||
func _display_palette() -> void:
|
||||
@ -180,12 +180,12 @@ func _refresh_hint_tooltip(_index : int) -> void:
|
||||
|
||||
|
||||
func _on_LeftColor_pressed() -> void:
|
||||
color_picker.color = Tools.get_assigned_color(BUTTON_LEFT)
|
||||
color_picker.color = DrawGD.tools.get_assigned_color(BUTTON_LEFT)
|
||||
_on_EditPaletteColorPicker_color_changed(color_picker.color)
|
||||
|
||||
|
||||
func _on_RightColor_pressed() -> void:
|
||||
color_picker.color = Tools.get_assigned_color(BUTTON_RIGHT)
|
||||
color_picker.color = DrawGD.tools.get_assigned_color(BUTTON_RIGHT)
|
||||
_on_EditPaletteColorPicker_color_changed(color_picker.color)
|
||||
|
||||
|
||||
|
@ -267,9 +267,9 @@ func on_color_select(index : int) -> void:
|
||||
var color : Color = DrawGD.palettes[current_palette].get_color(index)
|
||||
|
||||
if Input.is_action_just_pressed("left_mouse"):
|
||||
Tools.assign_color(color, BUTTON_LEFT)
|
||||
DrawGD.tools.assign_color(color, BUTTON_LEFT)
|
||||
elif Input.is_action_just_pressed("right_mouse"):
|
||||
Tools.assign_color(color, BUTTON_RIGHT)
|
||||
DrawGD.tools.assign_color(color, BUTTON_RIGHT)
|
||||
|
||||
|
||||
func _load_palettes() -> void:
|
||||
|
@ -1,8 +1,7 @@
|
||||
extends VBoxContainer
|
||||
|
||||
|
||||
var kname : String
|
||||
var tool_slot : Tools.Slot = null
|
||||
var tool_slot = null
|
||||
var cursor_text := ""
|
||||
|
||||
var _cursor := Vector2.INF
|
||||
@ -29,7 +28,7 @@ func _on_Horizontal_toggled(button_pressed : bool):
|
||||
tool_slot.save_config()
|
||||
DrawGD.show_y_symmetry_axis = button_pressed
|
||||
# If the button is not pressed but another button is, keep the symmetry guide visible
|
||||
if !button_pressed and (Tools._slots[BUTTON_LEFT].horizontal_mirror or Tools._slots[BUTTON_RIGHT].horizontal_mirror):
|
||||
if !button_pressed and (DrawGD.tools._slots[BUTTON_LEFT].horizontal_mirror or DrawGD.tools._slots[BUTTON_RIGHT].horizontal_mirror):
|
||||
DrawGD.show_y_symmetry_axis = true
|
||||
DrawGD.current_project.y_symmetry_axis.visible = DrawGD.show_y_symmetry_axis and DrawGD.show_guides
|
||||
|
||||
@ -39,7 +38,7 @@ func _on_Vertical_toggled(button_pressed : bool):
|
||||
tool_slot.save_config()
|
||||
DrawGD.show_x_symmetry_axis = button_pressed
|
||||
# If the button is not pressed but another button is, keep the symmetry guide visible
|
||||
if !button_pressed and (Tools._slots[BUTTON_LEFT].vertical_mirror or Tools._slots[BUTTON_RIGHT].vertical_mirror):
|
||||
if !button_pressed and (DrawGD.tools._slots[BUTTON_LEFT].vertical_mirror or DrawGD.tools._slots[BUTTON_RIGHT].vertical_mirror):
|
||||
DrawGD.show_x_symmetry_axis = true
|
||||
DrawGD.current_project.x_symmetry_axis.visible = DrawGD.show_x_symmetry_axis and DrawGD.show_guides
|
||||
|
||||
|
@ -48,4 +48,4 @@ func _pick_color(position : Vector2) -> void:
|
||||
image.lock()
|
||||
var color := image.get_pixelv(position)
|
||||
var button := BUTTON_LEFT if _color_slot == 0 else BUTTON_RIGHT
|
||||
Tools.assign_color(color, button)
|
||||
DrawGD.tools.assign_color(color, button)
|
||||
|
@ -22,7 +22,7 @@ var _polylines := []
|
||||
var _line_polylines := []
|
||||
|
||||
func _ready() -> void:
|
||||
Tools.connect("color_changed", self, "_on_Color_changed")
|
||||
DrawGD.tools.connect("color_changed", self, "_on_Color_changed")
|
||||
DrawGD.brushes_popup.connect("brush_removed", self, "_on_Brush_removed")
|
||||
|
||||
|
||||
@ -181,7 +181,7 @@ func draw_tool(position : Vector2) -> void:
|
||||
return
|
||||
var strength := _strength
|
||||
if DrawGD.pressure_sensitivity_mode == DrawGD.Pressure_Sensitivity.ALPHA:
|
||||
strength *= Tools.pen_pressure
|
||||
strength *= DrawGD.tools.pen_pressure
|
||||
|
||||
_drawer.pixel_perfect = tool_slot.pixel_perfect if _brush_size == 1 else false
|
||||
_drawer.horizontal_mirror = tool_slot.horizontal_mirror
|
||||
@ -344,8 +344,8 @@ func _set_pixel(position : Vector2) -> void:
|
||||
|
||||
var image := _get_draw_image()
|
||||
var i := int(position.x + position.y * image.get_size().x)
|
||||
if _mask[i] < Tools.pen_pressure:
|
||||
_mask[i] = Tools.pen_pressure
|
||||
if _mask[i] < DrawGD.tools.pen_pressure:
|
||||
_mask[i] = DrawGD.tools.pen_pressure
|
||||
_drawer.set_pixel(image, position, tool_slot.color)
|
||||
|
||||
|
||||
@ -484,7 +484,7 @@ func _line_angle_constraint(start : Vector2, end : Vector2) -> Dictionary:
|
||||
var result := {}
|
||||
var angle := rad2deg(end.angle_to_point(start))
|
||||
var distance := start.distance_to(end)
|
||||
if Tools.control:
|
||||
if DrawGD.tools.control:
|
||||
if tool_slot.pixel_perfect:
|
||||
angle = stepify(angle, 22.5)
|
||||
if step_decimals(angle) != 0:
|
||||
|
@ -31,7 +31,7 @@ func draw_start(position : Vector2) -> void:
|
||||
prepare_undo()
|
||||
_drawer.reset()
|
||||
|
||||
_draw_line = Tools.shift
|
||||
_draw_line = DrawGD.tools.shift
|
||||
if _draw_line:
|
||||
_line_start = position
|
||||
_line_end = position
|
||||
|
@ -71,7 +71,7 @@ func draw_start(position : Vector2) -> void:
|
||||
prepare_undo()
|
||||
_drawer.reset()
|
||||
|
||||
_draw_line = Tools.shift
|
||||
_draw_line = DrawGD.tools.shift
|
||||
if _draw_line:
|
||||
_line_start = position
|
||||
_line_end = position
|
||||
|
@ -54,7 +54,7 @@ func draw_start(position : Vector2) -> void:
|
||||
prepare_undo()
|
||||
_drawer.reset()
|
||||
|
||||
_draw_line = Tools.shift
|
||||
_draw_line = DrawGD.tools.shift
|
||||
if _draw_line:
|
||||
_line_start = position
|
||||
_line_end = position
|
||||
|
@ -11,7 +11,7 @@ func draw_start(position : Vector2) -> void:
|
||||
if DrawGD.selection_rectangle.has_point(position):
|
||||
_move = true
|
||||
_offset = position
|
||||
DrawGD.selection_rectangle.move_start(Tools.shift)
|
||||
DrawGD.selection_rectangle.move_start(DrawGD.tools.shift)
|
||||
_set_cursor_text(DrawGD.selection_rectangle.get_rect())
|
||||
else:
|
||||
_drag = true
|
||||
|
@ -72,7 +72,7 @@ func _input(event : InputEvent) -> void:
|
||||
DrawGD.left_cursor.visible = false
|
||||
DrawGD.right_cursor.visible = false
|
||||
|
||||
Tools.handle_draw(current_pixel.floor(), event)
|
||||
DrawGD.tools.handle_draw(current_pixel.floor(), event)
|
||||
|
||||
if sprite_changed_this_frame:
|
||||
update_texture(current_project.current_layer)
|
||||
|
@ -9,4 +9,4 @@ func _input(event : InputEvent) -> void:
|
||||
func _draw() -> void:
|
||||
# Draw rectangle to indicate the pixel currently being hovered on
|
||||
if DrawGD.has_focus and DrawGD.can_draw:
|
||||
Tools.draw_indicator()
|
||||
DrawGD.tools.draw_indicator()
|
||||
|
@ -6,18 +6,18 @@ onready var right_picker := $ColorButtonsVertical/ColorPickersCenter/ColorPicker
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Tools.connect("color_changed", self, "update_color")
|
||||
DrawGD.tools.connect("color_changed", self, "update_color")
|
||||
left_picker.get_picker().presets_visible = false
|
||||
right_picker.get_picker().presets_visible = false
|
||||
|
||||
|
||||
func _on_ColorSwitch_pressed() -> void:
|
||||
Tools.swap_color()
|
||||
DrawGD.tools.swap_color()
|
||||
|
||||
|
||||
func _on_ColorPickerButton_color_changed(color : Color, right : bool):
|
||||
var button := BUTTON_RIGHT if right else BUTTON_LEFT
|
||||
Tools.assign_color(color, button)
|
||||
DrawGD.tools.assign_color(color, button)
|
||||
|
||||
|
||||
func _on_ColorPickerButton_pressed() -> void:
|
||||
@ -29,7 +29,7 @@ func _on_ColorPickerButton_popup_closed() -> void:
|
||||
|
||||
|
||||
func _on_ColorDefaults_pressed() -> void:
|
||||
Tools.default_color()
|
||||
DrawGD.tools.default_color()
|
||||
|
||||
|
||||
func update_color(color : Color, button : int) -> void:
|
||||
|
@ -27,9 +27,9 @@ func _input(event : InputEvent) -> void:
|
||||
return
|
||||
for t in tools: # Handle tool shortcuts
|
||||
if event.is_action_pressed("right_" + t[1] + "_tool"): # Shortcut for right button (with Alt)
|
||||
Tools.assign_tool(t[0].name, BUTTON_RIGHT)
|
||||
DrawGD.tools.assign_tool(t[0].name, BUTTON_RIGHT)
|
||||
elif event.is_action_pressed("left_" + t[1] + "_tool"): # Shortcut for left button
|
||||
Tools.assign_tool(t[0].name, BUTTON_LEFT)
|
||||
DrawGD.tools.assign_tool(t[0].name, BUTTON_LEFT)
|
||||
|
||||
|
||||
func _on_Tool_pressed(tool_pressed : BaseButton) -> void:
|
||||
@ -37,4 +37,4 @@ func _on_Tool_pressed(tool_pressed : BaseButton) -> void:
|
||||
button = BUTTON_LEFT if Input.is_action_just_released("left_mouse") else button
|
||||
button = BUTTON_RIGHT if Input.is_action_just_released("right_mouse") else button
|
||||
if button != -1:
|
||||
Tools.assign_tool(tool_pressed.name, button)
|
||||
DrawGD.tools.assign_tool(tool_pressed.name, button)
|
||||
|
Loading…
Reference in New Issue
Block a user