2019-12-18 16:12:44 +00:00
|
|
|
extends AcceptDialog
|
|
|
|
|
2019-12-20 14:36:23 +00:00
|
|
|
func _ready() -> void:
|
|
|
|
if Global.config_cache.has_section_key("preferences", "theme"):
|
|
|
|
var theme_id = Global.config_cache.get_value("preferences", "theme")
|
|
|
|
change_theme(theme_id)
|
|
|
|
$VBoxContainer/OptionsContainer/ThemeOption.selected = theme_id
|
|
|
|
|
2019-12-18 16:12:44 +00:00
|
|
|
func _on_LanguageOption_item_selected(ID : int) -> void:
|
|
|
|
if ID == 0:
|
|
|
|
TranslationServer.set_locale(OS.get_locale())
|
|
|
|
else:
|
|
|
|
TranslationServer.set_locale(Global.loaded_locales[ID - 1])
|
|
|
|
if Global.loaded_locales[ID - 1] == "zh_TW":
|
|
|
|
Global.control.theme.default_font = preload("res://Assets/Fonts/NotoSansCJKtc-Regular.tres")
|
|
|
|
else:
|
|
|
|
Global.control.theme.default_font = preload("res://Assets/Fonts/Roboto-Regular.tres")
|
|
|
|
|
|
|
|
Global.config_cache.set_value("preferences", "locale", TranslationServer.get_locale())
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
|
|
|
|
2019-12-18 23:18:57 +00:00
|
|
|
func _on_ThemeOption_item_selected(ID : int) -> void:
|
2019-12-20 14:36:23 +00:00
|
|
|
change_theme(ID)
|
|
|
|
|
|
|
|
Global.config_cache.set_value("preferences", "theme", ID)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
|
|
|
|
|
|
|
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-21 02:56:48 +00:00
|
|
|
Global.transparent_background.create_from_image(preload("res://Assets/Graphics/Transparent Background Dark.png"), 0)
|
|
|
|
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-21 02:56:48 +00:00
|
|
|
Global.transparent_background.create_from_image(preload("res://Assets/Graphics/Transparent Background Godot.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-21 02:56:48 +00:00
|
|
|
Global.transparent_background.create_from_image(preload("res://Assets/Graphics/Transparent Background Godot.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/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-21 01:02:57 +00:00
|
|
|
Global.theme_type = "Light"
|
2019-12-21 02:56:48 +00:00
|
|
|
Global.transparent_background.create_from_image(preload("res://Assets/Graphics/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-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-18 16:12:44 +00:00
|
|
|
func _on_GridWidthValue_value_changed(value : float) -> void:
|
|
|
|
Global.grid_width = value
|
|
|
|
|
|
|
|
func _on_GridHeightValue_value_changed(value : float) -> void:
|
|
|
|
Global.grid_height = value
|
|
|
|
|
|
|
|
func _on_GridColor_color_changed(color : Color) -> void:
|
2019-12-18 23:18:57 +00:00
|
|
|
Global.grid_color = color
|