2019-12-18 16:12:44 +00:00
|
|
|
extends AcceptDialog
|
|
|
|
|
2019-12-26 23:02:36 +00:00
|
|
|
onready var tree : Tree = $HSplitContainer/Tree
|
|
|
|
onready var right_side : VBoxContainer = $HSplitContainer/ScrollContainer/VBoxContainer
|
2020-02-07 01:27:11 +00:00
|
|
|
onready var general = $HSplitContainer/ScrollContainer/VBoxContainer/General
|
2019-12-26 23:02:36 +00:00
|
|
|
onready var languages = $HSplitContainer/ScrollContainer/VBoxContainer/Languages
|
2019-12-27 00:12:26 +00:00
|
|
|
onready var themes = $HSplitContainer/ScrollContainer/VBoxContainer/Themes
|
2020-04-18 07:03:18 +00:00
|
|
|
onready var canvas = $HSplitContainer/ScrollContainer/VBoxContainer/Canvas
|
2020-01-10 08:06:03 +00:00
|
|
|
onready var image = $HSplitContainer/ScrollContainer/VBoxContainer/Image
|
2020-04-07 22:56:05 +00:00
|
|
|
onready var shortcuts = $HSplitContainer/ScrollContainer/VBoxContainer/Shortcuts
|
2019-12-26 23:02:36 +00:00
|
|
|
|
2020-04-21 17:45:02 +00:00
|
|
|
onready var open_last_project_button = $HSplitContainer/ScrollContainer/VBoxContainer/General/OpenLastProject
|
2020-04-18 07:03:18 +00:00
|
|
|
onready var smooth_zoom_button = $HSplitContainer/ScrollContainer/VBoxContainer/General/SmoothZoom
|
|
|
|
onready var sensitivity_option = $HSplitContainer/ScrollContainer/VBoxContainer/General/PressureSentivity/PressureSensitivityOptionButton
|
2020-04-10 19:40:14 +00:00
|
|
|
onready var left_tool_icon = $HSplitContainer/ScrollContainer/VBoxContainer/General/GridContainer/LeftToolIconCheckbox
|
|
|
|
onready var right_tool_icon = $HSplitContainer/ScrollContainer/VBoxContainer/General/GridContainer/RightToolIconCheckbox
|
2020-02-11 17:45:36 +00:00
|
|
|
|
2020-01-10 19:24:07 +00:00
|
|
|
onready var default_width_value = $HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions/ImageDefaultWidth
|
|
|
|
onready var default_height_value = $HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions/ImageDefaultHeight
|
|
|
|
onready var default_fill_color = $HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions/DefaultFillColor
|
2019-12-26 23:02:36 +00:00
|
|
|
|
2020-04-18 07:03:18 +00:00
|
|
|
onready var grid_width_value = $HSplitContainer/ScrollContainer/VBoxContainer/Canvas/GridOptions/GridWidthValue
|
|
|
|
onready var grid_height_value = $HSplitContainer/ScrollContainer/VBoxContainer/Canvas/GridOptions/GridHeightValue
|
|
|
|
onready var grid_color = $HSplitContainer/ScrollContainer/VBoxContainer/Canvas/GridOptions/GridColor
|
|
|
|
onready var guide_color = $HSplitContainer/ScrollContainer/VBoxContainer/Canvas/GuideOptions/GuideColor
|
|
|
|
|
|
|
|
onready var checker_size_value = $HSplitContainer/ScrollContainer/VBoxContainer/Canvas/CheckerOptions/CheckerSizeValue
|
|
|
|
onready var checker_color_1 = $HSplitContainer/ScrollContainer/VBoxContainer/Canvas/CheckerOptions/CheckerColor1
|
|
|
|
onready var checker_color_2 = $HSplitContainer/ScrollContainer/VBoxContainer/Canvas/CheckerOptions/CheckerColor2
|
2020-01-09 22:12:36 +00:00
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2019-12-20 14:36:23 +00:00
|
|
|
func _ready() -> void:
|
2020-04-30 17:33:24 +00:00
|
|
|
# Replace OK with Close since preference changes are being applied immediately, not after OK confirmation
|
|
|
|
get_ok().text = tr("Close")
|
|
|
|
|
2020-02-11 17:45:36 +00:00
|
|
|
# Set default values for General options
|
2020-04-21 17:45:02 +00:00
|
|
|
if Global.config_cache.has_section_key("preferences", "open_last_project"):
|
|
|
|
Global.open_last_project = Global.config_cache.get_value("preferences", "open_last_project")
|
|
|
|
open_last_project_button.pressed = Global.open_last_project
|
2020-02-11 17:45:36 +00:00
|
|
|
if Global.config_cache.has_section_key("preferences", "smooth_zoom"):
|
|
|
|
Global.smooth_zoom = Global.config_cache.get_value("preferences", "smooth_zoom")
|
|
|
|
smooth_zoom_button.pressed = Global.smooth_zoom
|
|
|
|
if Global.config_cache.has_section_key("preferences", "pressure_sensitivity"):
|
|
|
|
Global.pressure_sensitivity_mode = Global.config_cache.get_value("preferences", "pressure_sensitivity")
|
|
|
|
sensitivity_option.selected = Global.pressure_sensitivity_mode
|
2020-04-11 02:36:51 +00:00
|
|
|
|
2020-04-10 19:40:14 +00:00
|
|
|
if Global.config_cache.has_section_key("preferences", "show_left_tool_icon"):
|
|
|
|
Global.show_left_tool_icon = Global.config_cache.get_value("preferences", "show_left_tool_icon")
|
|
|
|
left_tool_icon.pressed = Global.show_left_tool_icon
|
|
|
|
if Global.config_cache.has_section_key("preferences", "show_right_tool_icon"):
|
|
|
|
Global.show_right_tool_icon = Global.config_cache.get_value("preferences", "show_right_tool_icon")
|
|
|
|
right_tool_icon.pressed = Global.show_right_tool_icon
|
2020-02-11 17:45:36 +00:00
|
|
|
|
2020-04-30 17:33:24 +00:00
|
|
|
# Get autosave settings
|
|
|
|
if Global.config_cache.has_section_key("preferences", "autosave_interval"):
|
|
|
|
var autosave_interval = Global.config_cache.get_value("preferences", "autosave_interval")
|
|
|
|
OpenSave.set_autosave_interval(autosave_interval)
|
|
|
|
general.get_node("AutosaveInterval/AutosaveInterval").value = autosave_interval
|
|
|
|
if Global.config_cache.has_section_key("preferences", "enable_autosave"):
|
|
|
|
var enable_autosave = Global.config_cache.get_value("preferences", "enable_autosave")
|
|
|
|
OpenSave.toggle_autosave(enable_autosave)
|
|
|
|
general.get_node("EnableAutosave").pressed = enable_autosave
|
|
|
|
|
2020-04-18 07:03:18 +00:00
|
|
|
# Set default values for Canvas options
|
2020-01-09 22:12:36 +00:00
|
|
|
if Global.config_cache.has_section_key("preferences", "grid_size"):
|
|
|
|
var grid_size = Global.config_cache.get_value("preferences", "grid_size")
|
|
|
|
Global.grid_width = int(grid_size.x)
|
|
|
|
Global.grid_height = int(grid_size.y)
|
|
|
|
grid_width_value.value = grid_size.x
|
|
|
|
grid_height_value.value = grid_size.y
|
|
|
|
|
|
|
|
if Global.config_cache.has_section_key("preferences", "grid_color"):
|
|
|
|
Global.grid_color = Global.config_cache.get_value("preferences", "grid_color")
|
|
|
|
grid_color.color = Global.grid_color
|
|
|
|
|
2020-04-18 07:03:18 +00:00
|
|
|
if Global.config_cache.has_section_key("preferences", "checker_size"):
|
|
|
|
var checker_size = Global.config_cache.get_value("preferences", "checker_size")
|
|
|
|
Global.checker_size = int(checker_size)
|
|
|
|
checker_size_value.value = checker_size
|
|
|
|
|
|
|
|
if Global.config_cache.has_section_key("preferences", "checker_color_1"):
|
|
|
|
Global.checker_color_1 = Global.config_cache.get_value("preferences", "checker_color_1")
|
|
|
|
checker_color_1.color = Global.checker_color_1
|
|
|
|
|
|
|
|
if Global.config_cache.has_section_key("preferences", "checker_color_2"):
|
|
|
|
Global.checker_color_2 = Global.config_cache.get_value("preferences", "checker_color_2")
|
|
|
|
checker_color_2.color = Global.checker_color_2
|
|
|
|
|
2020-04-20 16:12:22 +00:00
|
|
|
Global.transparent_checker._ready()
|
|
|
|
|
2020-01-09 22:12:36 +00:00
|
|
|
if Global.config_cache.has_section_key("preferences", "guide_color"):
|
|
|
|
Global.guide_color = Global.config_cache.get_value("preferences", "guide_color")
|
|
|
|
for canvas in Global.canvases:
|
|
|
|
for guide in canvas.get_children():
|
|
|
|
if guide is Guide:
|
|
|
|
guide.default_color = Global.guide_color
|
|
|
|
guide_color.color = Global.guide_color
|
2020-01-10 22:29:29 +00:00
|
|
|
|
2020-01-10 19:24:07 +00:00
|
|
|
# Set default values for Image
|
2020-01-10 22:14:56 +00:00
|
|
|
if Global.config_cache.has_section_key("preferences", "default_width"):
|
2020-01-10 19:24:07 +00:00
|
|
|
var default_width = Global.config_cache.get_value("preferences", "default_width")
|
|
|
|
Global.default_image_width = int(default_width)
|
|
|
|
default_width_value.value = Global.default_image_width
|
2020-01-10 22:14:56 +00:00
|
|
|
|
|
|
|
if Global.config_cache.has_section_key("preferences", "default_height"):
|
|
|
|
var default_height = Global.config_cache.get_value("preferences", "default_height")
|
|
|
|
Global.default_image_height = int(default_height)
|
2020-01-10 19:24:07 +00:00
|
|
|
default_height_value.value = Global.default_image_height
|
2020-01-10 22:29:29 +00:00
|
|
|
|
2020-01-10 19:24:07 +00:00
|
|
|
if Global.config_cache.has_section_key("preferences", "default_fill_color"):
|
|
|
|
var fill_color = Global.config_cache.get_value("preferences", "default_fill_color")
|
|
|
|
Global.default_fill_color = fill_color
|
|
|
|
default_fill_color.color = Global.default_fill_color
|
2020-01-09 22:12:36 +00:00
|
|
|
|
2020-04-18 07:03:18 +00:00
|
|
|
guide_color.get_picker().presets_visible = false
|
|
|
|
grid_color.get_picker().presets_visible = false
|
|
|
|
checker_color_1.get_picker().presets_visible = false
|
|
|
|
checker_color_2.get_picker().presets_visible = false
|
|
|
|
default_fill_color.get_picker().presets_visible = false
|
2020-02-15 05:34:42 +00:00
|
|
|
|
2020-04-07 22:56:05 +00:00
|
|
|
|
2020-02-07 21:27:05 +00:00
|
|
|
func _on_PreferencesDialog_about_to_show(changed_language := false) -> void:
|
2019-12-26 23:02:36 +00:00
|
|
|
var root := tree.create_item()
|
2020-02-07 01:27:11 +00:00
|
|
|
var general_button := tree.create_item(root)
|
2019-12-26 23:02:36 +00:00
|
|
|
var language_button := tree.create_item(root)
|
|
|
|
var theme_button := tree.create_item(root)
|
2020-04-18 07:03:18 +00:00
|
|
|
var canvas_button := tree.create_item(root)
|
2020-01-10 08:06:03 +00:00
|
|
|
var image_button := tree.create_item(root)
|
2020-04-07 22:56:05 +00:00
|
|
|
var shortcuts_button := tree.create_item(root)
|
2019-12-31 23:27:34 +00:00
|
|
|
|
2020-02-07 01:27:11 +00:00
|
|
|
general_button.set_text(0, " " + tr("General"))
|
2019-12-31 23:27:34 +00:00
|
|
|
# We use metadata to avoid being affected by translations
|
2020-02-07 01:27:11 +00:00
|
|
|
general_button.set_metadata(0, "General")
|
|
|
|
language_button.set_text(0, " " + tr("Language"))
|
2019-12-31 17:04:54 +00:00
|
|
|
language_button.set_metadata(0, "Language")
|
|
|
|
theme_button.set_text(0, " " + tr("Themes"))
|
|
|
|
theme_button.set_metadata(0, "Themes")
|
2020-04-18 07:03:18 +00:00
|
|
|
canvas_button.set_text(0, " " + tr("Canvas"))
|
|
|
|
canvas_button.set_metadata(0, "Canvas")
|
2020-01-10 08:06:03 +00:00
|
|
|
image_button.set_text(0, " " + tr("Image"))
|
|
|
|
image_button.set_metadata(0, "Image")
|
2020-04-07 22:56:05 +00:00
|
|
|
shortcuts_button.set_text(0, " " + tr("Shortcuts"))
|
|
|
|
shortcuts_button.set_metadata(0, "Shortcuts")
|
2019-12-26 23:02:36 +00:00
|
|
|
|
2020-02-07 21:27:05 +00:00
|
|
|
if changed_language:
|
|
|
|
language_button.select(0)
|
|
|
|
else:
|
|
|
|
general_button.select(0)
|
2020-02-07 01:27:11 +00:00
|
|
|
|
2020-05-05 13:03:32 +00:00
|
|
|
general.get_node("AutosaveInterval/AutosaveInterval").suffix = tr("minute(s)")
|
|
|
|
|
2019-12-27 00:12:26 +00:00
|
|
|
|
2019-12-31 23:27:34 +00:00
|
|
|
func _on_PreferencesDialog_popup_hide() -> void:
|
|
|
|
tree.clear()
|
2019-12-20 14:36:23 +00:00
|
|
|
|
2020-04-07 22:56:05 +00:00
|
|
|
|
2019-12-26 23:02:36 +00:00
|
|
|
func _on_Tree_item_selected() -> void:
|
|
|
|
for child in right_side.get_children():
|
|
|
|
child.visible = false
|
2019-12-31 17:04:54 +00:00
|
|
|
var selected : String = tree.get_selected().get_metadata(0)
|
2020-02-07 01:27:11 +00:00
|
|
|
if "General" in selected:
|
|
|
|
general.visible = true
|
|
|
|
elif "Language" in selected:
|
2019-12-26 23:02:36 +00:00
|
|
|
languages.visible = true
|
|
|
|
elif "Themes" in selected:
|
2019-12-27 00:12:26 +00:00
|
|
|
themes.visible = true
|
2020-04-18 07:03:18 +00:00
|
|
|
elif "Canvas" in selected:
|
|
|
|
canvas.visible = true
|
2020-01-10 08:06:03 +00:00
|
|
|
elif "Image" in selected:
|
|
|
|
image.visible = true
|
2020-04-07 22:56:05 +00:00
|
|
|
elif "Shortcuts" in selected:
|
|
|
|
shortcuts.visible = true
|
|
|
|
|
2019-12-26 23:02:36 +00:00
|
|
|
|
2020-02-07 21:27:05 +00:00
|
|
|
func _on_PressureSensitivityOptionButton_item_selected(id : int) -> void:
|
|
|
|
Global.pressure_sensitivity_mode = id
|
2020-02-11 17:45:36 +00:00
|
|
|
Global.config_cache.set_value("preferences", "pressure_sensitivity", id)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2020-02-07 21:27:05 +00:00
|
|
|
|
2020-04-07 22:56:05 +00:00
|
|
|
|
2020-02-07 01:27:11 +00:00
|
|
|
func _on_SmoothZoom_pressed() -> void:
|
|
|
|
Global.smooth_zoom = !Global.smooth_zoom
|
2020-02-11 17:45:36 +00:00
|
|
|
Global.config_cache.set_value("preferences", "smooth_zoom", Global.smooth_zoom)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2020-02-07 01:27:11 +00:00
|
|
|
|
2020-04-07 22:56:05 +00:00
|
|
|
|
2019-12-18 16:12:44 +00:00
|
|
|
func _on_GridWidthValue_value_changed(value : float) -> void:
|
|
|
|
Global.grid_width = value
|
2020-01-08 01:48:01 +00:00
|
|
|
Global.canvas.update()
|
2020-01-09 22:12:36 +00:00
|
|
|
Global.config_cache.set_value("preferences", "grid_size", Vector2(value, grid_height_value.value))
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2019-12-18 16:12:44 +00:00
|
|
|
|
2020-04-07 22:56:05 +00:00
|
|
|
|
2019-12-18 16:12:44 +00:00
|
|
|
func _on_GridHeightValue_value_changed(value : float) -> void:
|
|
|
|
Global.grid_height = value
|
2020-01-08 01:48:01 +00:00
|
|
|
Global.canvas.update()
|
2020-01-09 22:12:36 +00:00
|
|
|
Global.config_cache.set_value("preferences", "grid_size", Vector2(grid_width_value.value, value))
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2019-12-18 16:12:44 +00:00
|
|
|
|
2020-04-07 22:56:05 +00:00
|
|
|
|
2019-12-18 16:12:44 +00:00
|
|
|
func _on_GridColor_color_changed(color : Color) -> void:
|
2019-12-18 23:18:57 +00:00
|
|
|
Global.grid_color = color
|
2020-01-08 01:48:01 +00:00
|
|
|
Global.canvas.update()
|
2020-01-09 22:12:36 +00:00
|
|
|
Global.config_cache.set_value("preferences", "grid_color", color)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2019-12-27 00:28:36 +00:00
|
|
|
|
2020-04-07 22:56:05 +00:00
|
|
|
|
2020-04-18 07:03:18 +00:00
|
|
|
func _on_CheckerSize_value_changed(value : float) -> void:
|
|
|
|
Global.checker_size = value
|
2020-04-20 16:12:22 +00:00
|
|
|
Global.transparent_checker._ready()
|
2020-04-18 07:03:18 +00:00
|
|
|
Global.config_cache.set_value("preferences", "checker_size", value)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
|
|
|
|
|
|
|
|
|
|
|
func _on_CheckerColor1_color_changed(color : Color) -> void:
|
|
|
|
Global.checker_color_1 = color
|
2020-04-20 16:12:22 +00:00
|
|
|
Global.transparent_checker._ready()
|
2020-04-18 07:03:18 +00:00
|
|
|
Global.config_cache.set_value("preferences", "checker_color_1", color)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
|
|
|
|
|
|
|
|
|
|
|
func _on_CheckerColor2_color_changed(color : Color) -> void:
|
|
|
|
Global.checker_color_2 = color
|
2020-04-20 16:12:22 +00:00
|
|
|
Global.transparent_checker._ready()
|
2020-04-18 07:03:18 +00:00
|
|
|
Global.config_cache.set_value("preferences", "checker_color_2", color)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
|
|
|
|
|
|
|
|
2019-12-27 00:28:36 +00:00
|
|
|
func _on_GuideColor_color_changed(color : Color) -> void:
|
|
|
|
Global.guide_color = color
|
|
|
|
for canvas in Global.canvases:
|
|
|
|
for guide in canvas.get_children():
|
|
|
|
if guide is Guide:
|
|
|
|
guide.default_color = color
|
2020-01-09 22:12:36 +00:00
|
|
|
Global.config_cache.set_value("preferences", "guide_color", color)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2020-01-10 22:29:29 +00:00
|
|
|
|
2020-04-07 22:56:05 +00:00
|
|
|
|
2020-01-10 08:06:03 +00:00
|
|
|
func _on_ImageDefaultWidth_value_changed(value: float) -> void:
|
|
|
|
Global.default_image_width = value
|
2020-01-10 19:24:07 +00:00
|
|
|
Global.config_cache.set_value("preferences", "default_width", value)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2020-01-10 08:06:03 +00:00
|
|
|
|
2020-04-07 22:56:05 +00:00
|
|
|
|
2020-01-10 08:06:03 +00:00
|
|
|
func _on_ImageDefaultHeight_value_changed(value: float) -> void:
|
|
|
|
Global.default_image_height = value
|
2020-01-10 19:24:07 +00:00
|
|
|
Global.config_cache.set_value("preferences", "default_height", value)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2020-01-10 22:29:29 +00:00
|
|
|
|
2020-03-27 01:40:23 +00:00
|
|
|
|
2020-01-10 08:06:03 +00:00
|
|
|
func _on_DefaultBackground_color_changed(color: Color) -> void:
|
2020-01-10 19:24:07 +00:00
|
|
|
Global.default_fill_color = color
|
|
|
|
Global.config_cache.set_value("preferences", "default_fill_color", color)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2020-03-27 01:40:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_LeftIndicatorCheckbox_toggled(button_pressed : bool) -> void:
|
2020-04-11 02:36:51 +00:00
|
|
|
Global.left_square_indicator_visible = button_pressed
|
2020-03-27 01:40:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_RightIndicatorCheckbox_toggled(button_pressed : bool) -> void:
|
|
|
|
Global.right_square_indicator_visible = button_pressed
|
|
|
|
|
|
|
|
|
|
|
|
func _on_LeftToolIconCheckbox_toggled(button_pressed : bool) -> void:
|
|
|
|
Global.show_left_tool_icon = button_pressed
|
2020-04-10 19:40:14 +00:00
|
|
|
Global.config_cache.set_value("preferences", "show_left_tool_icon", Global.show_left_tool_icon)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2020-03-27 01:40:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_RightToolIconCheckbox_toggled(button_pressed : bool) -> void:
|
|
|
|
Global.show_right_tool_icon = button_pressed
|
2020-04-10 19:40:14 +00:00
|
|
|
Global.config_cache.set_value("preferences", "show_right_tool_icon", Global.show_right_tool_icon)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2020-04-07 22:56:05 +00:00
|
|
|
|
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
func _on_OpenLastProject_pressed() -> void:
|
2020-04-21 17:45:02 +00:00
|
|
|
Global.open_last_project = !Global.open_last_project
|
|
|
|
Global.config_cache.set_value("preferences", "open_last_project", Global.open_last_project)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2020-04-30 17:33:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_EnableAutosave_toggled(button_pressed : bool) -> void:
|
|
|
|
OpenSave.toggle_autosave(button_pressed)
|
|
|
|
Global.config_cache.set_value("preferences", "enable_autosave", button_pressed)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
|
|
|
|
|
|
|
|
|
|
|
func _on_AutosaveInterval_value_changed(value : float) -> void:
|
|
|
|
OpenSave.set_autosave_interval(value)
|
|
|
|
Global.config_cache.set_value("preferences", "autosave_interval", value)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|