4 ## Editor that contains all settings
6 var button_group := ButtonGroup.new()
7 var registered_sections: Array[DialogicSettingsPage] = []
10 func _get_title() -> String:
14 func _get_icon() -> Texture:
15 return get_theme_icon("PluginScript", "EditorIcons")
18 func _register() -> void:
19 editors_manager.register_simple_editor(self)
20 self.alternative_text = "Customize dialogic and it's behaviour"
23 func _ready() -> void:
24 if get_parent() is SubViewport:
27 register_settings_section("res://addons/dialogic/Editor/Settings/settings_general.tscn")
28 register_settings_section("res://addons/dialogic/Editor/Settings/settings_translation.tscn")
29 register_settings_section("res://addons/dialogic/Editor/Settings/settings_modules.tscn")
31 for indexer in DialogicUtil.get_indexers():
32 for settings_page in indexer._get_settings_pages():
33 register_settings_section(settings_page)
35 add_registered_sections()
36 %SettingsTabs.get_child(0).button_pressed = true
37 %SettingsContent.get_child(0).show()
40 func register_settings_section(path:String) -> void:
41 var section: Control = load(path).instantiate()
42 registered_sections.append(section)
45 func add_registered_sections() -> void:
46 for i in %SettingsTabs.get_children():
48 for i in %FeatureTabs.get_children():
51 for i in %SettingsContent.get_children():
55 registered_sections.sort_custom(section_sort)
56 for section in registered_sections:
58 section.name = section._get_title()
60 var vbox := VBoxContainer.new()
61 vbox.set_meta('section', section)
62 vbox.size_flags_vertical = Control.SIZE_EXPAND_FILL
63 vbox.name = section.name
64 var hbox := HBoxContainer.new()
66 var title := Label.new()
67 title.text = section.name
68 title.theme_type_variation = 'DialogicSectionBig'
73 if !section.short_info.is_empty():
74 var tooltip_hint: Control = load("res://addons/dialogic/Editor/Common/hint_tooltip_icon.tscn").instantiate()
75 tooltip_hint.hint_text = section.short_info
76 hbox.add_child(tooltip_hint)
79 var scroll := ScrollContainer.new()
80 scroll.size_flags_horizontal = Control.SIZE_EXPAND_FILL
81 scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
82 var inner_vbox := VBoxContainer.new()
83 inner_vbox.size_flags_horizontal = Control.SIZE_EXPAND_FILL
84 inner_vbox.size_flags_vertical = Control.SIZE_EXPAND_FILL
85 scroll.add_child(inner_vbox)
86 var panel := PanelContainer.new()
87 panel.theme_type_variation = "DialogicPanelA"
88 panel.size_flags_horizontal = Control.SIZE_EXPAND_FILL
89 if section.size_flags_vertical == Control.SIZE_EXPAND_FILL:
90 panel.size_flags_vertical = Control.SIZE_EXPAND_FILL
91 inner_vbox.add_child(panel)
94 var info_section: Control = section._get_info_section()
95 if info_section != null:
96 inner_vbox.add_child(Control.new())
97 inner_vbox.get_child(-1).custom_minimum_size.y = 50
99 inner_vbox.add_child(title.duplicate())
100 inner_vbox.get_child(-1).text = "Information"
101 var info_panel := panel.duplicate()
102 info_panel.theme_type_variation = "DialogicPanelDarkA"
104 inner_vbox.add_child(info_panel)
105 info_section.get_parent().remove_child(info_section)
106 info_panel.add_child(info_section)
108 panel.add_child(section)
109 vbox.add_child(scroll)
112 var button := Button.new()
113 button.text = " "+section.name
114 button.tooltip_text = section.name
115 button.toggle_mode = true
116 button.button_group = button_group
117 button.expand_icon = true
118 button.alignment = HORIZONTAL_ALIGNMENT_LEFT
120 button.add_theme_color_override('font_pressed_color', get_theme_color("property_color_z", "Editor"))
121 button.add_theme_color_override('font_hover_color', get_theme_color('warning_color', 'Editor'))
122 button.add_theme_color_override('font_focus_color', get_theme_color('warning_color', 'Editor'))
123 button.add_theme_stylebox_override('focus', StyleBoxEmpty.new())
124 button.pressed.connect(open_tab.bind(vbox))
125 if section._is_feature_tab():
126 %FeatureTabs.add_child(button)
128 %SettingsTabs.add_child(button)
131 # if section.has_method('_get_icon'):
132 # icon.texture = section._get_icon()
133 %SettingsContent.add_child(vbox)
136 func open_tab(tab_to_show:Control) -> void:
137 for tab in %SettingsContent.get_children():
143 func section_sort(item1:DialogicSettingsPage, item2:DialogicSettingsPage) -> bool:
144 if !item1._is_feature_tab() and item2._is_feature_tab():
146 if item1._get_priority() > item2._get_priority():
152 func _open(extra_information:Variant = null) -> void:
154 if typeof(extra_information) == TYPE_STRING:
155 if %SettingsContent.has_node(extra_information):
156 open_tab(%SettingsContent.get_node(extra_information))
159 func _close() -> void:
160 for child in %SettingsContent.get_children():
161 if child.get_meta('section').has_method('_about_to_close'):
162 child.get_meta('section')._about_to_close()
165 func refresh() -> void:
166 for child in %SettingsContent.get_children():
167 if child.get_meta('section').has_method('_refresh'):
168 child.get_meta('section')._refresh()