No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ThemeEditor.gd 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. tool
  2. extends Control
  3. var editor_reference
  4. onready var master_tree = get_node('../MasterTreeContainer/MasterTree')
  5. onready var settings_editor = get_node('../SettingsEditor')
  6. var current_theme = ''
  7. # When loading the variables to the input fields in the
  8. # load_theme function, every element thinks the value was updated
  9. # so it has to perform a "saving" of that property.
  10. # The loading variable is a way to check if the values should be saved
  11. # or not.
  12. var loading = true
  13. # The amazing and revolutionary path system that magically works and you can't
  14. # complain because "that is not how you are supposed to work". If there was only
  15. # a way to set an id and then access that node via id...
  16. # Here you have paths in all its glory. Praise the paths (っ´ω`c)♡
  17. onready var n = {
  18. # Text
  19. 'theme_text_shadow': $VBoxContainer/TabContainer/Text/Column/GridContainer/HBoxContainer2/CheckBoxShadow,
  20. 'theme_text_shadow_color': $VBoxContainer/TabContainer/Text/Column/GridContainer/HBoxContainer2/ColorPickerButtonShadow,
  21. 'theme_text_color': $VBoxContainer/TabContainer/Text/Column/GridContainer/ColorPickerButton,
  22. 'theme_font': $VBoxContainer/TabContainer/Text/Column/GridContainer/FontButton,
  23. 'theme_shadow_offset_x': $VBoxContainer/TabContainer/Text/Column/GridContainer/HBoxContainer/ShadowOffsetX,
  24. 'theme_shadow_offset_y': $VBoxContainer/TabContainer/Text/Column/GridContainer/HBoxContainer/ShadowOffsetY,
  25. 'theme_text_speed': $VBoxContainer/TabContainer/Text/Column/GridContainer/TextSpeed,
  26. 'alignment': $VBoxContainer/TabContainer/Text/Column/GridContainer/HBoxContainer3/Alignment,
  27. # Dialog box
  28. 'background_texture_button_visible': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/HBoxContainer3/CheckBox",
  29. 'theme_background_image': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/HBoxContainer3/BackgroundTextureButton",
  30. 'theme_next_image': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/NextIndicatorButton",
  31. 'next_animation': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/NextAnimation",
  32. 'theme_action_key': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/BoxContainer/ActionOptionButton",
  33. 'theme_background_color_visible': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/HBoxContainer2/CheckBox",
  34. 'theme_background_color': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/HBoxContainer2/ColorPickerButton",
  35. 'theme_text_margin': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/HBoxContainer/TextOffsetV",
  36. 'theme_text_margin_h': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/HBoxContainer/TextOffsetH",
  37. 'size_w': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/HBoxContainer4/BoxSizeW",
  38. 'size_h': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/HBoxContainer4/BoxSizeH",
  39. 'bottom_gap': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/HBoxContainer5/BottomGap",
  40. 'background_modulation': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/HBoxContainer6/CheckBox",
  41. 'background_modulation_color': $"VBoxContainer/TabContainer/Dialog Box/Column/GridContainer/HBoxContainer6/ColorPickerButton",
  42. # Buttons
  43. 'button_text_color_enabled': $"VBoxContainer/TabContainer/Choice Buttons/Column/GridContainer/HBoxContainer4/CheckBox2",
  44. 'button_text_color': $"VBoxContainer/TabContainer/Choice Buttons/Column/GridContainer/HBoxContainer4/ButtonTextColor",
  45. 'button_background': $"VBoxContainer/TabContainer/Choice Buttons/Column/GridContainer/HBoxContainer2/ColorPickerButton",
  46. 'button_background_visible': $"VBoxContainer/TabContainer/Choice Buttons/Column/GridContainer/HBoxContainer2/CheckBox",
  47. 'button_image': $"VBoxContainer/TabContainer/Choice Buttons/Column/GridContainer/HBoxContainer3/BackgroundTextureButton",
  48. 'button_image_visible': $"VBoxContainer/TabContainer/Choice Buttons/Column/GridContainer/HBoxContainer3/CheckBox",
  49. 'button_offset_x': $"VBoxContainer/TabContainer/Choice Buttons/Column/GridContainer/HBoxContainer/TextOffsetH",
  50. 'button_offset_y': $"VBoxContainer/TabContainer/Choice Buttons/Column/GridContainer/HBoxContainer/TextOffsetV",
  51. 'button_separation': $"VBoxContainer/TabContainer/Choice Buttons/Column/GridContainer/VerticalSeparation",
  52. # Definitions
  53. 'glossary_font': $VBoxContainer/TabContainer/Glossary/Column/GridContainer/FontButton,
  54. 'glossary_color': $VBoxContainer/TabContainer/Glossary/Column/GridContainer/ColorPickerButton,
  55. # Text preview
  56. 'text_preview': $VBoxContainer/HBoxContainer3/TextEdit,
  57. # Character Names
  58. 'name_auto_color': $"VBoxContainer/TabContainer/Name Label/Column/GridContainer/CheckBox",
  59. 'name_background_visible': $"VBoxContainer/TabContainer/Name Label/Column/GridContainer/HBoxContainer2/CheckBox",
  60. 'name_background': $"VBoxContainer/TabContainer/Name Label/Column/GridContainer/HBoxContainer2/ColorPickerButton",
  61. 'name_image': $"VBoxContainer/TabContainer/Name Label/Column/GridContainer/HBoxContainer3/BackgroundTextureButton",
  62. 'name_image_visible': $"VBoxContainer/TabContainer/Name Label/Column/GridContainer/HBoxContainer3/CheckBox",
  63. 'name_shadow': $"VBoxContainer/TabContainer/Name Label/Column/GridContainer/HBoxContainer4/ColorPickerButtonShadow",
  64. 'name_shadow_visible': $"VBoxContainer/TabContainer/Name Label/Column/GridContainer/HBoxContainer4/CheckBoxShadow",
  65. 'name_shadow_offset_x': $"VBoxContainer/TabContainer/Name Label/Column/GridContainer/HBoxContainer/ShadowOffsetX",
  66. 'name_shadow_offset_y': $"VBoxContainer/TabContainer/Name Label/Column/GridContainer/HBoxContainer/ShadowOffsetY",
  67. 'name_bottom_gap': $"VBoxContainer/TabContainer/Name Label/Column/GridContainer/HBoxContainer5/BottomGap",
  68. }
  69. func _ready():
  70. # Signal connection to free up some memory
  71. connect("visibility_changed", self, "_on_visibility_changed")
  72. if get_constant("dark_theme", "Editor"):
  73. $VBoxContainer/HBoxContainer3/PreviewButton.icon = load("res://addons/dialogic/Images/Plugin/plugin-editor-icon-dark-theme.svg")
  74. else:
  75. $VBoxContainer/HBoxContainer3/PreviewButton.icon = load("res://addons/dialogic/Images/Plugin/plugin-editor-icon-light-theme.svg")
  76. $DelayPreviewTimer.one_shot = true
  77. $DelayPreviewTimer.connect("timeout", self, '_on_DelayPreview_timer_timeout')
  78. # Force preview update
  79. _on_visibility_changed()
  80. func load_theme(filename):
  81. loading = true
  82. current_theme = filename
  83. var theme = DialogicResources.get_theme_config(filename)
  84. # Settings
  85. n['theme_action_key'].text = theme.get_value('settings', 'action_key', 'ui_accept')
  86. # Background
  87. n['theme_background_image'].text = DialogicResources.get_filename_from_path(theme.get_value('background', 'image', 'res://addons/dialogic/Images/background/background-2.png'))
  88. n['background_texture_button_visible'].pressed = theme.get_value('background', 'use_image', true)
  89. n['theme_background_color'].color = Color(theme.get_value('background', 'color', '#ff000000'))
  90. n['theme_background_color_visible'].pressed = theme.get_value('background', 'use_color', false)
  91. n['theme_next_image'].text = DialogicResources.get_filename_from_path(theme.get_value('next_indicator', 'image', 'res://addons/dialogic/Images/next-indicator.png'))
  92. n['background_modulation'].pressed = theme.get_value('background', 'modulation', false)
  93. n['background_modulation_color'].color = Color(theme.get_value('background', 'modulation_color', '#ffffffff'))
  94. var size_value = theme.get_value('box', 'size', Vector2(910, 167))
  95. n['size_w'].value = size_value.x
  96. n['size_h'].value = size_value.y
  97. n['bottom_gap'].value = theme.get_value('box', 'bottom_gap', 40)
  98. # Buttons
  99. n['button_text_color_enabled'].pressed = theme.get_value('buttons', 'text_color_enabled', true)
  100. n['button_text_color'].color = Color(theme.get_value('buttons', 'text_color', "#ffffffff"))
  101. n['button_background'].color = Color(theme.get_value('buttons', 'background_color', "#ff000000"))
  102. n['button_background_visible'].pressed = theme.get_value('buttons', 'use_background_color', false)
  103. n['button_image'].text = DialogicResources.get_filename_from_path(theme.get_value('buttons', 'image', 'res://addons/dialogic/Images/background/background-2.png'))
  104. n['button_image_visible'].pressed = theme.get_value('buttons', 'use_image', true)
  105. n['button_offset_x'].value = theme.get_value('buttons', 'padding', Vector2(5,5)).x
  106. n['button_offset_y'].value = theme.get_value('buttons', 'padding', Vector2(5,5)).y
  107. n['button_separation'].value = theme.get_value('buttons', 'gap', 5)
  108. # Definitions
  109. n['glossary_color'].color = Color(theme.get_value('definitions', 'color', "#ffffffff"))
  110. n['glossary_font'].text = DialogicResources.get_filename_from_path(theme.get_value('definitions', 'font', "res://addons/dialogic/Fonts/GlossaryFont.tres"))
  111. # Text
  112. n['theme_text_speed'].value = theme.get_value('text','speed', 2)
  113. n['theme_font'].text = DialogicResources.get_filename_from_path(theme.get_value('text', 'font', 'res://addons/dialogic/Fonts/DefaultFont.tres'))
  114. n['theme_text_color'].color = Color(theme.get_value('text', 'color', '#ffffffff'))
  115. n['theme_text_shadow'].pressed = theme.get_value('text', 'shadow', false)
  116. n['theme_text_shadow_color'].color = Color(theme.get_value('text', 'shadow_color', '#9e000000'))
  117. n['theme_shadow_offset_x'].value = theme.get_value('text', 'shadow_offset', Vector2(2,2)).x
  118. n['theme_shadow_offset_y'].value = theme.get_value('text', 'shadow_offset', Vector2(2,2)).y
  119. n['theme_text_margin'].value = theme.get_value('text', 'margin', Vector2(20, 10)).x
  120. n['theme_text_margin_h'].value = theme.get_value('text', 'margin', Vector2(20, 10)).y
  121. n['alignment'].text = theme.get_value('text', 'alignment', 'Left')
  122. match n['alignment'].text:
  123. 'Left':
  124. n['alignment'].select(0)
  125. 'Center':
  126. n['alignment'].select(1)
  127. 'Right':
  128. n['alignment'].select(2)
  129. # Name
  130. n['name_auto_color'].pressed = theme.get_value('name', 'auto_color', true)
  131. n['name_background_visible'].pressed = theme.get_value('name', 'background_visible', false)
  132. n['name_background'].color = Color(theme.get_value('name', 'background', "#ff000000"))
  133. n['name_image_visible'].pressed = theme.get_value('name', 'image_visible', false)
  134. n['name_image'].text = DialogicResources.get_filename_from_path(theme.get_value('name', 'image', 'res://addons/dialogic/Images/background/background-2.png'))
  135. n['name_shadow'].color = Color(theme.get_value('name', 'shadow', "#9e000000"))
  136. n['name_shadow_visible'].pressed = theme.get_value('name', 'shadow_visible', true)
  137. n['name_shadow_offset_x'].value = theme.get_value('name', 'shadow_offset', Vector2(2,2)).x
  138. n['name_shadow_offset_y'].value = theme.get_value('name', 'shadow_offset', Vector2(2,2)).y
  139. n['name_bottom_gap'].value = theme.get_value('name', 'bottom_gap', 48)
  140. # Next indicator animations
  141. var animations = ['Up and down', 'Pulse', 'Static'] # TODO: dynamically get all the animations from the Dialog.tscn NextIndicator
  142. n['next_animation'].clear()
  143. var next_animation_selected = theme.get_value('next_indicator', 'animation', 'Up and down')
  144. var nix = 0
  145. for a in animations:
  146. n['next_animation'].add_item(a)
  147. if a == next_animation_selected:
  148. n['next_animation'].select(nix)
  149. nix += 1
  150. # Preview text
  151. n['text_preview'].text = theme.get_value('text', 'preview', 'This is preview text. You can use [color=#A5EFAC]BBCode[/color] to style it.\n[wave amp=50 freq=2]You can even use effects![/wave]')
  152. # Finished loading
  153. loading = false
  154. # Updating the preview
  155. _on_PreviewButton_pressed()
  156. func new_theme():
  157. var theme_file = 'theme-' + str(OS.get_unix_time()) + '.cfg'
  158. DialogicResources.add_theme(theme_file)
  159. master_tree.build_themes(theme_file)
  160. load_theme(theme_file)
  161. # Check if it is the only theme to set as default
  162. if DialogicUtil.get_theme_list().size() == 1:
  163. #print('only theme, setting as default')
  164. settings_editor.set_value('theme', 'default', theme_file)
  165. func duplicate_theme(from_filename):
  166. var duplicate_theme = 'theme-' + str(OS.get_unix_time()) + '.cfg'
  167. DialogicResources.duplicate_theme(from_filename, duplicate_theme)
  168. DialogicResources.set_theme_value(duplicate_theme, 'settings', 'name', duplicate_theme)
  169. master_tree.build_themes(duplicate_theme)
  170. load_theme(duplicate_theme)
  171. func _on_BackgroundTextureButton_pressed():
  172. editor_reference.godot_dialog("*.png")
  173. editor_reference.godot_dialog_connect(self, "_on_background_selected")
  174. func _on_background_selected(path, target):
  175. if loading == true:
  176. return
  177. DialogicResources.set_theme_value(current_theme, 'background','image', path)
  178. n['theme_background_image'].text = DialogicResources.get_filename_from_path(path)
  179. _on_PreviewButton_pressed() # Refreshing the preview
  180. func _on_NextIndicatorButton_pressed():
  181. editor_reference.godot_dialog("*.png")
  182. editor_reference.godot_dialog_connect(self, "_on_indicator_selected")
  183. func _on_indicator_selected(path, target):
  184. if loading == true:
  185. return
  186. DialogicResources.set_theme_value(current_theme, 'next_indicator','image', path)
  187. n['theme_next_image'].text = DialogicResources.get_filename_from_path(path)
  188. _on_PreviewButton_pressed() # Refreshing the preview
  189. func _on_NextAnimation_item_selected(index):
  190. DialogicResources.set_theme_value(current_theme, 'next_indicator', 'animation', n['next_animation'].get_item_text(index))
  191. _on_PreviewButton_pressed() # Refreshing the preview
  192. func _on_ColorPickerButton_color_changed(color):
  193. if loading == true:
  194. return
  195. DialogicResources.set_theme_value(current_theme, 'text','color', '#' + color.to_html())
  196. $DelayPreviewTimer.start(0.5) # Calling a timer so the update doesn't get triggered many times
  197. func _on_ColorPickerButtonShadow_color_changed(color):
  198. if loading == true:
  199. return
  200. DialogicResources.set_theme_value(current_theme, 'text','shadow_color', '#' + color.to_html())
  201. $DelayPreviewTimer.start(0.5) # Calling a timer so the update doesn't get triggered many times
  202. func _on_CheckBoxShadow_toggled(button_pressed):
  203. if loading == true:
  204. return
  205. DialogicResources.set_theme_value(current_theme, 'text','shadow', button_pressed)
  206. _on_PreviewButton_pressed() # Refreshing the preview
  207. func _on_ShadowOffset_value_changed(_value):
  208. if loading == true:
  209. return
  210. DialogicResources.set_theme_value(current_theme, 'text','shadow_offset', Vector2(n['theme_shadow_offset_x'].value,n['theme_shadow_offset_y'].value))
  211. _on_PreviewButton_pressed() # Refreshing the preview
  212. func _on_PreviewButton_pressed():
  213. for i in $VBoxContainer/Panel.get_children():
  214. i.free()
  215. var dialogic_node = load("res://addons/dialogic/Dialog.tscn")
  216. var preview_dialog = dialogic_node.instance()
  217. preview_dialog.timeline = ''
  218. preview_dialog.preview = true
  219. preview_dialog.debug_mode = false
  220. preview_dialog.get_node('DefinitionInfo').in_theme_editor = true
  221. # Random character preview if there are any
  222. var characters = DialogicUtil.get_character_list()
  223. var character_file = ''
  224. if characters.size():
  225. characters.shuffle()
  226. character_file = characters[0]['file']
  227. # Loading the theme here because I need it for the parse_alignment
  228. preview_dialog.current_theme = preview_dialog.load_theme(current_theme)
  229. # Creating the one event timeline for the dialog
  230. var text = preview_dialog.parse_definitions(n['text_preview'].text)
  231. preview_dialog.dialog_script['events'] = [{
  232. "character": character_file,
  233. "portrait":'',
  234. "text": text
  235. }]
  236. preview_dialog.parse_characters(preview_dialog.dialog_script)
  237. preview_dialog.settings = DialogicResources.get_settings_config()
  238. # Alignment
  239. $VBoxContainer/Panel.add_child(preview_dialog)
  240. preview_dialog.load_dialog()
  241. # Reloading the theme
  242. preview_dialog.current_theme = preview_dialog.load_theme(current_theme)
  243. # When not performing this step, the dialog name doesn't update the color for some reason
  244. # I should probably refactor the preview dialog to stop making everything manually.
  245. if n['name_auto_color'].pressed:
  246. if characters.size():
  247. preview_dialog.get_node('TextBubble/NameLabel').set('custom_colors/font_color', characters[0]['color'])
  248. # maintaining the preview panel big enough for the dialog box
  249. $VBoxContainer/Panel.rect_min_size.y = preview_dialog.current_theme.get_value('box', 'size', Vector2(910, 167)).y + 90 + preview_dialog.current_theme.get_value('box', 'bottom_gap', 40)
  250. $VBoxContainer/Panel.rect_size.y = 0
  251. func _on_ActionOptionButton_item_selected(index):
  252. if loading == true:
  253. return
  254. DialogicResources.set_theme_value(current_theme, 'settings','action_key', n['theme_action_key'].text)
  255. func _on_ActionOptionButton_pressed():
  256. n['theme_action_key'].clear()
  257. n['theme_action_key'].add_item('[Select Action]')
  258. InputMap.load_from_globals()
  259. for a in InputMap.get_actions():
  260. n['theme_action_key'].add_item(a)
  261. func _on_FontButton_pressed():
  262. editor_reference.godot_dialog("*.tres")
  263. editor_reference.godot_dialog_connect(self, "_on_Font_selected")
  264. func _on_Font_selected(path, target):
  265. if loading == true:
  266. return
  267. DialogicResources.set_theme_value(current_theme, 'text','font', path)
  268. n['theme_font'].text = DialogicResources.get_filename_from_path(path)
  269. _on_PreviewButton_pressed() # Refreshing the preview
  270. func _on_textSpeed_value_changed(value):
  271. if loading == true:
  272. return
  273. DialogicResources.set_theme_value(current_theme, 'text','speed', value)
  274. _on_PreviewButton_pressed() # Refreshing the preview
  275. func _on_TextMargin_value_changed(value):
  276. if loading == true:
  277. return
  278. var final_vector = Vector2(
  279. n['theme_text_margin'].value,
  280. n['theme_text_margin_h'].value
  281. )
  282. DialogicResources.set_theme_value(current_theme, 'text', 'margin', final_vector)
  283. _on_PreviewButton_pressed() # Refreshing the preview
  284. func _on_BackgroundColor_CheckBox_toggled(button_pressed):
  285. if loading == true:
  286. return
  287. DialogicResources.set_theme_value(current_theme, 'background', 'use_color', button_pressed)
  288. _on_PreviewButton_pressed() # Refreshing the preview
  289. func _on_BackgroundColor_ColorPickerButton_color_changed(color):
  290. if loading == true:
  291. return
  292. DialogicResources.set_theme_value(current_theme, 'background', 'color', '#' + color.to_html())
  293. $DelayPreviewTimer.start(0.5) # Calling a timer so the update doesn't get triggered many times
  294. func _on_BackgroundTexture_CheckBox_toggled(button_pressed):
  295. if loading == true:
  296. return
  297. DialogicResources.set_theme_value(current_theme, 'background', 'use_image', button_pressed)
  298. _on_PreviewButton_pressed() # Refreshing the preview
  299. func _on_button_background_visible_toggled(button_pressed):
  300. if loading == true:
  301. return
  302. DialogicResources.set_theme_value(current_theme, 'buttons', 'use_background_color', button_pressed)
  303. func _on_button_background_color_color_changed(color):
  304. if loading == true:
  305. return
  306. DialogicResources.set_theme_value(current_theme, 'buttons', 'background_color', '#' + color.to_html())
  307. $DelayPreviewTimer.start(0.5) # Calling a timer so the update doesn't get triggered many times
  308. func _on_ButtonOffset_value_changed(value):
  309. if loading == true:
  310. return
  311. var final_vector = Vector2(
  312. n['button_offset_x'].value,
  313. n['button_offset_y'].value
  314. )
  315. DialogicResources.set_theme_value(current_theme, 'buttons', 'padding', final_vector)
  316. func _on_VerticalSeparation_value_changed(value):
  317. if loading == true:
  318. return
  319. DialogicResources.set_theme_value(current_theme, 'buttons', 'gap', n['button_separation'].value)
  320. func _on_button_texture_toggled(button_pressed):
  321. if loading == true:
  322. return
  323. DialogicResources.set_theme_value(current_theme, 'buttons', 'use_image', button_pressed)
  324. func _on_ButtonTextureButton_pressed():
  325. editor_reference.godot_dialog("*.png")
  326. editor_reference.godot_dialog_connect(self, "_on_button_texture_selected")
  327. func _on_button_texture_selected(path, target):
  328. if loading == true:
  329. return
  330. DialogicResources.set_theme_value(current_theme, 'buttons', 'image', path)
  331. n['button_image'].text = DialogicResources.get_filename_from_path(path)
  332. func _on_ButtonTextColor_color_changed(color):
  333. if loading == true:
  334. return
  335. DialogicResources.set_theme_value(current_theme, 'buttons', 'text_color', '#' + color.to_html())
  336. $DelayPreviewTimer.start(0.5) # Calling a timer so the update doesn't get triggered many times
  337. func _on_Custom_Button_Color_toggled(button_pressed):
  338. if loading == true:
  339. return
  340. DialogicResources.set_theme_value(current_theme, 'buttons', 'text_color_enabled', button_pressed)
  341. func _on_GlossaryColorPicker_color_changed(color):
  342. if loading == true:
  343. return
  344. DialogicResources.set_theme_value(current_theme, 'definitions', 'color', '#' + color.to_html())
  345. $DelayPreviewTimer.start(0.5) # Calling a timer so the update doesn't get triggered many times
  346. func _on_GlossaryFontButton_pressed():
  347. editor_reference.godot_dialog("*.tres")
  348. editor_reference.godot_dialog_connect(self, "_on_Glossary_Font_selected")
  349. func _on_Glossary_Font_selected(path, target):
  350. if loading == true:
  351. return
  352. DialogicResources.set_theme_value(current_theme, 'definitions', 'font', path)
  353. n['glossary_font'].text = DialogicResources.get_filename_from_path(path)
  354. _on_PreviewButton_pressed() # Refreshing the preview
  355. func _on_visibility_changed():
  356. if visible:
  357. # Refreshing the dialog
  358. _on_PreviewButton_pressed()
  359. else:
  360. # Erasing all previews since them keeps working
  361. # on background
  362. for i in $VBoxContainer/Panel.get_children():
  363. i.queue_free()
  364. func _on_BoxSize_value_changed(value):
  365. if loading == true:
  366. return
  367. var size_value = Vector2(n['size_w'].value, n['size_h'].value)
  368. DialogicResources.set_theme_value(current_theme, 'box', 'size', size_value)
  369. _on_PreviewButton_pressed() # Refreshing the preview
  370. func _on_BottomGap_value_changed(value):
  371. if loading == true:
  372. return
  373. DialogicResources.set_theme_value(current_theme, 'box', 'bottom_gap', value)
  374. _on_PreviewButton_pressed() # Refreshing the preview
  375. func _on_Alignment_item_selected(index):
  376. if loading == true:
  377. return
  378. if index == 0:
  379. DialogicResources.set_theme_value(current_theme, 'text', 'alignment', 'Left')
  380. elif index == 1:
  381. DialogicResources.set_theme_value(current_theme, 'text', 'alignment', 'Center')
  382. elif index == 2:
  383. DialogicResources.set_theme_value(current_theme, 'text', 'alignment', 'Right')
  384. _on_PreviewButton_pressed() # Refreshing the preview
  385. func _on_Preview_text_changed():
  386. if loading == true:
  387. return
  388. DialogicResources.set_theme_value(current_theme, 'text', 'preview', n['text_preview'].text)
  389. func _on_name_auto_color_toggled(button_pressed):
  390. if loading == true:
  391. return
  392. DialogicResources.set_theme_value(current_theme, 'name', 'auto_color', button_pressed)
  393. _on_PreviewButton_pressed() # Refreshing the preview
  394. func _on_name_background_visible_toggled(button_pressed):
  395. if loading == true:
  396. return
  397. DialogicResources.set_theme_value(current_theme, 'name', 'background_visible', button_pressed)
  398. _on_PreviewButton_pressed() # Refreshing the preview
  399. func _on_name_background_color_changed(color):
  400. if loading == true:
  401. return
  402. DialogicResources.set_theme_value(current_theme, 'name', 'background', '#' + color.to_html())
  403. $DelayPreviewTimer.start(0.5) # Calling a timer so the update doesn't get triggered many times
  404. func _on_name_image_visible_toggled(button_pressed):
  405. if loading == true:
  406. return
  407. DialogicResources.set_theme_value(current_theme, 'name', 'image_visible', button_pressed)
  408. _on_PreviewButton_pressed() # Refreshing the preview
  409. func _on_name_image_pressed():
  410. editor_reference.godot_dialog("*.png")
  411. editor_reference.godot_dialog_connect(self, "_on_name_texture_selected")
  412. func _on_name_texture_selected(path, target):
  413. if loading == true:
  414. return
  415. DialogicResources.set_theme_value(current_theme, 'name', 'image', path)
  416. n['name_image'].text = DialogicResources.get_filename_from_path(path)
  417. _on_PreviewButton_pressed() # Refreshing the preview
  418. func _on_shadow_visible_toggled(button_pressed):
  419. if loading == true:
  420. return
  421. DialogicResources.set_theme_value(current_theme, 'name', 'shadow_visible', button_pressed)
  422. _on_PreviewButton_pressed() # Refreshing the preview
  423. func _on_name_shadow_color_changed(color):
  424. if loading == true:
  425. return
  426. DialogicResources.set_theme_value(current_theme, 'name', 'shadow', '#' + color.to_html())
  427. $DelayPreviewTimer.start(0.5) # Calling a timer so the update doesn't get triggered many times
  428. func _on_name_ShadowOffset_value_changed(_value):
  429. if loading == true:
  430. return
  431. DialogicResources.set_theme_value(current_theme, 'name','shadow_offset',
  432. Vector2(n['name_shadow_offset_x'].value,n['name_shadow_offset_y'].value))
  433. _on_PreviewButton_pressed() # Refreshing the preview
  434. func _on_name_BottomGap_value_changed(value):
  435. if loading == true:
  436. return
  437. DialogicResources.set_theme_value(current_theme, 'name', 'bottom_gap', value)
  438. _on_PreviewButton_pressed() # Refreshing the preview
  439. func _on_DelayPreview_timer_timeout():
  440. _on_PreviewButton_pressed() # Refreshing the preview
  441. func _on_BackgroundTexture_Modulation_toggled(button_pressed):
  442. if loading == true:
  443. return
  444. DialogicResources.set_theme_value(current_theme, 'background', 'modulation', button_pressed)
  445. _on_PreviewButton_pressed() # Refreshing the preview
  446. func _on_ColorPicker_Background_texture_modulation_color_changed(color):
  447. if loading == true:
  448. return
  449. DialogicResources.set_theme_value(current_theme, 'background', 'modulation_color', '#' + color.to_html())
  450. $DelayPreviewTimer.start(0.5) # Calling a timer so the update doesn't get triggered many times