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
|
2019-12-26 23:02:36 +00:00
|
|
|
onready var grid_guides = $"HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides"
|
2020-01-10 08:06:03 +00:00
|
|
|
onready var image = $HSplitContainer/ScrollContainer/VBoxContainer/Image
|
2019-12-26 23:02: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-01-09 22:12:36 +00:00
|
|
|
onready var grid_width_value = $"HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides/GridOptions/GridWidthValue"
|
|
|
|
onready var grid_height_value = $"HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides/GridOptions/GridHeightValue"
|
|
|
|
onready var grid_color = $"HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides/GridOptions/GridColor"
|
|
|
|
onready var guide_color = $"HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides/GridOptions/GuideColor"
|
|
|
|
|
2019-12-20 14:36:23 +00:00
|
|
|
func _ready() -> void:
|
2019-12-31 23:27:34 +00:00
|
|
|
for child in languages.get_children():
|
|
|
|
if child is Button:
|
|
|
|
child.connect("pressed", self, "_on_Language_pressed", [child])
|
2020-02-07 00:40:53 +00:00
|
|
|
child.hint_tooltip = child.name
|
2019-12-31 23:27:34 +00:00
|
|
|
|
|
|
|
for child in themes.get_children():
|
|
|
|
if child is Button:
|
|
|
|
child.connect("pressed", self, "_on_Theme_pressed", [child])
|
|
|
|
|
|
|
|
if Global.config_cache.has_section_key("preferences", "theme"):
|
|
|
|
var theme_id = Global.config_cache.get_value("preferences", "theme")
|
|
|
|
change_theme(theme_id)
|
|
|
|
themes.get_child(theme_id + 1).pressed = true
|
2020-01-07 00:37:47 +00:00
|
|
|
else:
|
|
|
|
change_theme(0)
|
|
|
|
themes.get_child(1).pressed = true
|
2019-12-31 23:27:34 +00:00
|
|
|
|
2020-01-09 22:12:36 +00:00
|
|
|
# Set default values for Grid & Guide options
|
|
|
|
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
|
|
|
|
|
|
|
|
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-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)
|
|
|
|
var grid_button := tree.create_item(root)
|
2020-01-10 08:06:03 +00:00
|
|
|
var image_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")
|
|
|
|
grid_button.set_text(0, " " + tr("Guides & Grid"))
|
|
|
|
grid_button.set_metadata(0, "Guides & Grid")
|
2020-01-10 08:06:03 +00:00
|
|
|
image_button.set_text(0, " " + tr("Image"))
|
|
|
|
image_button.set_metadata(0, "Image")
|
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
|
|
|
|
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
|
|
|
|
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
|
2019-12-26 23:02:36 +00:00
|
|
|
elif "Guides & Grid" in selected:
|
|
|
|
grid_guides.visible = true
|
2020-01-10 08:06:03 +00:00
|
|
|
elif "Image" in selected:
|
|
|
|
image.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-07 01:27:11 +00:00
|
|
|
func _on_SmoothZoom_pressed() -> void:
|
|
|
|
Global.smooth_zoom = !Global.smooth_zoom
|
|
|
|
|
2019-12-26 23:02:36 +00:00
|
|
|
func _on_Language_pressed(button : Button) -> void:
|
|
|
|
var index := 0
|
|
|
|
var i := -1
|
|
|
|
for child in languages.get_children():
|
|
|
|
if child is Button:
|
|
|
|
if child == button:
|
|
|
|
button.pressed = true
|
|
|
|
index = i
|
|
|
|
else:
|
|
|
|
child.pressed = false
|
|
|
|
i += 1
|
|
|
|
if index == -1:
|
2019-12-18 16:12:44 +00:00
|
|
|
TranslationServer.set_locale(OS.get_locale())
|
|
|
|
else:
|
2019-12-26 23:02:36 +00:00
|
|
|
TranslationServer.set_locale(Global.loaded_locales[index])
|
|
|
|
|
2020-01-02 14:46:31 +00:00
|
|
|
if "zh" in TranslationServer.get_locale():
|
2020-01-05 14:03:04 +00:00
|
|
|
Global.control.theme.default_font = preload("res://Assets/Fonts/CJK/NotoSansCJKtc-Regular.tres")
|
2019-12-26 23:02:36 +00:00
|
|
|
else:
|
|
|
|
Global.control.theme.default_font = preload("res://Assets/Fonts/Roboto-Regular.tres")
|
2019-12-18 16:12:44 +00:00
|
|
|
|
|
|
|
Global.config_cache.set_value("preferences", "locale", TranslationServer.get_locale())
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
|
|
|
|
2020-01-01 13:00:46 +00:00
|
|
|
# Update Translations
|
|
|
|
_on_PreferencesDialog_popup_hide()
|
2020-02-07 21:27:05 +00:00
|
|
|
_on_PreferencesDialog_about_to_show(true)
|
2020-01-01 13:00:46 +00:00
|
|
|
|
2019-12-27 00:12:26 +00:00
|
|
|
func _on_Theme_pressed(button : Button) -> void:
|
|
|
|
var index := 0
|
|
|
|
var i := 0
|
|
|
|
for child in themes.get_children():
|
|
|
|
if child is Button:
|
|
|
|
if child == button:
|
|
|
|
button.pressed = true
|
|
|
|
index = i
|
|
|
|
else:
|
|
|
|
child.pressed = false
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
change_theme(index)
|
2019-12-20 14:36:23 +00:00
|
|
|
|
2019-12-27 00:12:26 +00:00
|
|
|
Global.config_cache.set_value("preferences", "theme", index)
|
2019-12-20 14:36:23 +00:00
|
|
|
Global.config_cache.save("user://cache.ini")
|
|
|
|
|
2019-12-27 00:12:26 +00:00
|
|
|
|
2019-12-20 14:36:23 +00:00
|
|
|
func change_theme(ID : int) -> void:
|
2019-12-20 16:44:51 +00:00
|
|
|
var font = Global.control.theme.default_font
|
2019-12-18 23:18:57 +00:00
|
|
|
var main_theme
|
|
|
|
var top_menu_style
|
|
|
|
var ruler_style
|
2019-12-20 03:22:03 +00:00
|
|
|
if ID == 0: #Dark Theme
|
2019-12-21 01:02:57 +00:00
|
|
|
Global.theme_type = "Dark"
|
2019-12-31 16:04:00 +00:00
|
|
|
Global.transparent_background.create_from_image(preload("res://Assets/Graphics/Canvas Backgrounds/Transparent Background Dark.png"), 0)
|
2019-12-21 02:56:48 +00:00
|
|
|
VisualServer.set_default_clear_color(Color(0.247059, 0.25098, 0.247059))
|
2019-12-18 23:18:57 +00:00
|
|
|
main_theme = preload("res://Themes & Styles/Dark Theme/Dark Theme.tres")
|
|
|
|
top_menu_style = preload("res://Themes & Styles/Dark Theme/DarkTopMenuStyle.tres")
|
|
|
|
ruler_style = preload("res://Themes & Styles/Dark Theme/DarkRulerStyle.tres")
|
2019-12-20 03:22:03 +00:00
|
|
|
elif ID == 1: #Gray Theme
|
2019-12-21 01:02:57 +00:00
|
|
|
Global.theme_type = "Dark"
|
2019-12-31 16:04:00 +00:00
|
|
|
Global.transparent_background.create_from_image(preload("res://Assets/Graphics/Canvas Backgrounds/Transparent Background Gray.png"), 0)
|
2019-12-21 02:17:39 +00:00
|
|
|
VisualServer.set_default_clear_color(Color(0.301961, 0.301961, 0.301961))
|
2019-12-20 03:22:03 +00:00
|
|
|
main_theme = preload("res://Themes & Styles/Gray Theme/Gray Theme.tres")
|
|
|
|
top_menu_style = preload("res://Themes & Styles/Gray Theme/GrayTopMenuStyle.tres")
|
|
|
|
ruler_style = preload("res://Themes & Styles/Dark Theme/DarkRulerStyle.tres")
|
|
|
|
elif ID == 2: #Godot's Theme
|
2019-12-21 01:02:57 +00:00
|
|
|
Global.theme_type = "Dark"
|
2019-12-31 16:04:00 +00:00
|
|
|
Global.transparent_background.create_from_image(preload("res://Assets/Graphics/Canvas Backgrounds/Transparent Background Godot.png"), 0)
|
2019-12-21 03:03:57 +00:00
|
|
|
VisualServer.set_default_clear_color(Color(0.27451, 0.278431, 0.305882))
|
2019-12-20 03:22:03 +00:00
|
|
|
main_theme = preload("res://Themes & Styles/Godot\'s Theme/Godot\'s Theme.tres")
|
|
|
|
top_menu_style = preload("res://Themes & Styles/Godot\'s Theme/TopMenuStyle.tres")
|
|
|
|
ruler_style = preload("res://Themes & Styles/Godot\'s Theme/RulerStyle.tres")
|
2019-12-20 23:33:02 +00:00
|
|
|
elif ID == 3: #Gold Theme
|
2019-12-23 00:16:34 +00:00
|
|
|
Global.theme_type = "Gold"
|
2019-12-31 16:04:00 +00:00
|
|
|
Global.transparent_background.create_from_image(preload("res://Assets/Graphics/Canvas Backgrounds/Transparent Background Gold.png"), 0)
|
2019-12-21 02:17:39 +00:00
|
|
|
VisualServer.set_default_clear_color(Color(0.694118, 0.619608, 0.458824))
|
2019-12-20 23:33:02 +00:00
|
|
|
main_theme = preload("res://Themes & Styles/Gold Theme/Gold Theme.tres")
|
|
|
|
top_menu_style = preload("res://Themes & Styles/Gold Theme/GoldTopMenuStyle.tres")
|
|
|
|
ruler_style = preload("res://Themes & Styles/Gold Theme/GoldRulerStyle.tres")
|
2019-12-22 21:36:02 +00:00
|
|
|
elif ID == 4: #Light Theme
|
2019-12-23 00:16:34 +00:00
|
|
|
Global.theme_type = "Light"
|
2019-12-31 16:04:00 +00:00
|
|
|
Global.transparent_background.create_from_image(preload("res://Assets/Graphics/Canvas Backgrounds/Transparent Background Light.png"), 0)
|
2019-12-22 21:36:02 +00:00
|
|
|
VisualServer.set_default_clear_color(Color(0.705882, 0.705882, 0.705882))
|
|
|
|
main_theme = preload("res://Themes & Styles/Light Theme/Light Theme.tres")
|
|
|
|
top_menu_style = preload("res://Themes & Styles/Light Theme/LightTopMenuStyle.tres")
|
|
|
|
ruler_style = preload("res://Themes & Styles/Light Theme/LightRulerStyle.tres")
|
2019-12-18 23:18:57 +00:00
|
|
|
|
|
|
|
Global.control.theme = main_theme
|
2019-12-20 16:44:51 +00:00
|
|
|
Global.control.theme.default_font = font
|
2019-12-18 23:18:57 +00:00
|
|
|
Global.top_menu_container.add_stylebox_override("panel", top_menu_style)
|
|
|
|
Global.horizontal_ruler.add_stylebox_override("normal", ruler_style)
|
|
|
|
Global.horizontal_ruler.add_stylebox_override("pressed", ruler_style)
|
|
|
|
Global.horizontal_ruler.add_stylebox_override("hover", ruler_style)
|
|
|
|
Global.horizontal_ruler.add_stylebox_override("focus", ruler_style)
|
|
|
|
Global.vertical_ruler.add_stylebox_override("normal", ruler_style)
|
|
|
|
Global.vertical_ruler.add_stylebox_override("pressed", ruler_style)
|
|
|
|
Global.vertical_ruler.add_stylebox_override("hover", ruler_style)
|
|
|
|
Global.vertical_ruler.add_stylebox_override("focus", ruler_style)
|
2019-12-21 02:17:39 +00:00
|
|
|
|
2019-12-21 01:50:09 +00:00
|
|
|
for button in get_tree().get_nodes_in_group("UIButtons"):
|
|
|
|
var last_backslash = button.texture_normal.resource_path.get_base_dir().find_last("/")
|
|
|
|
var button_category = button.texture_normal.resource_path.get_base_dir().right(last_backslash + 1)
|
2019-12-21 01:27:11 +00:00
|
|
|
var normal_file_name = button.texture_normal.resource_path.get_file()
|
2019-12-21 01:50:09 +00:00
|
|
|
button.texture_normal = load("res://Assets/Graphics/%s Themes/%s/%s" % [Global.theme_type, button_category, normal_file_name])
|
2019-12-21 02:17:39 +00:00
|
|
|
if button.texture_pressed:
|
|
|
|
var pressed_file_name = button.texture_pressed.resource_path.get_file()
|
|
|
|
button.texture_pressed = load("res://Assets/Graphics/%s Themes/%s/%s" % [Global.theme_type, button_category, pressed_file_name])
|
2019-12-21 01:50:09 +00:00
|
|
|
if button.texture_hover:
|
|
|
|
var hover_file_name = button.texture_hover.resource_path.get_file()
|
|
|
|
button.texture_hover = load("res://Assets/Graphics/%s Themes/%s/%s" % [Global.theme_type, button_category, hover_file_name])
|
2019-12-21 01:02:57 +00:00
|
|
|
if button.texture_disabled:
|
2019-12-21 01:27:11 +00:00
|
|
|
var disabled_file_name = button.texture_disabled.resource_path.get_file()
|
2019-12-21 01:50:09 +00:00
|
|
|
button.texture_disabled = load("res://Assets/Graphics/%s Themes/%s/%s" % [Global.theme_type, button_category, disabled_file_name])
|
2019-12-18 23:18:57 +00:00
|
|
|
|
2019-12-24 02:37:17 +00:00
|
|
|
# Make sure the frame text gets updated
|
|
|
|
Global.current_frame = Global.current_frame
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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-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
|
|
|
|
|
|
|
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-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")
|