control.gd 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. extends Control
  2. var mainmenu_visible : bool = false #used to test if mainmenu is open
  3. var effect_position = Vector2(40,40) #tracks mouse position for node placement offset
  4. @onready var graph_edit = $GraphEdit
  5. var cdpprogs_location #stores the cdp programs location from user prefs for easy access
  6. var delete_intermediate_outputs # tracks state of delete intermediate outputs toggle
  7. @onready var console_output: RichTextLabel = $Console/ConsoleOutput
  8. var undo_redo := UndoRedo.new()
  9. var output_audio_player #tracks the node that is the current output player for linking
  10. var input_audio_player #tracks node that is the current input player for linking
  11. var currentfile = "none" #tracks dir of currently loaded file for saving
  12. var changesmade = false #tracks if user has made changes to the currently loaded save file
  13. var savestate # tracks what the user is trying to do when savechangespopup is called
  14. var helpfile #tracks which help file the user was trying to load when savechangespopup is called
  15. var outfilename #links to the user name for outputfile field
  16. var foldertoggle #links to the reuse folder button
  17. var lastoutputfolder = "none" #tracks last output folder, this can in future be used to replace global.outfile but i cba right now
  18. var uiscale = 1.0 #tracks scaling for retina screens
  19. #scripts
  20. var open_help
  21. var run_thread
  22. var save_load
  23. # Called when the node enters the scene tree for the first time.
  24. func _ready() -> void:
  25. Nodes.hide()
  26. $mainmenu.hide()
  27. $NoLocationPopup.hide()
  28. $Console.hide()
  29. $NoInputPopup.hide()
  30. $MultipleConnectionsPopup.hide()
  31. $AudioSettings.hide()
  32. $AudioDevicePopup.hide()
  33. $SearchMenu.hide()
  34. $Settings.hide()
  35. $ProgressWindow.hide()
  36. $SaveDialog.access = FileDialog.ACCESS_FILESYSTEM
  37. $SaveDialog.file_mode = FileDialog.FILE_MODE_SAVE_FILE
  38. $SaveDialog.filters = ["*.thd"]
  39. $LoadDialog.access = FileDialog.ACCESS_FILESYSTEM
  40. $LoadDialog.file_mode = FileDialog.FILE_MODE_OPEN_FILE
  41. $LoadDialog.filters = ["*.thd"]
  42. get_tree().set_auto_accept_quit(false) #disable closing the app with the x and instead handle it internally
  43. load_scripts()
  44. make_signal_connections()
  45. check_user_preferences()
  46. hidpi_adjustment()
  47. new_patch()
  48. check_cdp_location_set()
  49. func load_scripts():
  50. #load and initialise scripts
  51. open_help = preload("res://scenes/main/scripts/open_help.gd").new()
  52. open_help.init(self)
  53. add_child(open_help)
  54. run_thread = preload("res://scenes/main/scripts/run_thread.gd").new()
  55. run_thread.init(self, $ProgressWindow, $ProgressWindow/ProgressLabel, $ProgressWindow/ProgressBar, $GraphEdit, $Console, $Console/ConsoleOutput)
  56. add_child(run_thread)
  57. graph_edit.init(self, $GraphEdit, Callable(open_help, "show_help_for_node"), $MultipleConnectionsPopup)
  58. save_load = preload("res://scenes/main/scripts/save_load.gd").new()
  59. save_load.init(self, $GraphEdit, Callable(open_help, "show_help_for_node"), Callable(graph_edit, "_register_node_movement"), Callable(graph_edit, "_register_inputs_in_node"), Callable(self, "link_output"))
  60. add_child(save_load)
  61. func make_signal_connections():
  62. get_node("SearchMenu").make_node.connect(graph_edit._make_node)
  63. get_node("mainmenu").make_node.connect(graph_edit._make_node)
  64. get_node("mainmenu").open_help.connect(open_help.show_help_for_node)
  65. get_node("Settings").open_cdp_location.connect(show_cdp_location)
  66. get_node("Settings").console_on_top.connect(change_console_settings)
  67. func hidpi_adjustment():
  68. #checks if display is hidpi and scales ui accordingly hidpi - 144
  69. if DisplayServer.screen_get_dpi(0) >= 144:
  70. uiscale = 2.0
  71. get_window().content_scale_factor = uiscale
  72. #goes through popup_windows group and scales all popups and resizes them
  73. for window in get_tree().get_nodes_in_group("popup_windows"):
  74. window.size = window.size * uiscale
  75. window.content_scale_factor = uiscale
  76. #checks if user has opened a file from the system file menu and loads it
  77. var args = OS.get_cmdline_args()
  78. for arg in args:
  79. var path = arg.strip_edges()
  80. if FileAccess.file_exists(path) and path.get_extension().to_lower() == "thd":
  81. save_load.load_graph_edit(path)
  82. break
  83. func new_patch():
  84. #clear old patch
  85. graph_edit.clear_connections()
  86. for node in graph_edit.get_children():
  87. if node is GraphNode:
  88. node.queue_free()
  89. await get_tree().process_frame # Wait for nodes to actually be removed
  90. graph_edit.scroll_offset = Vector2(0, 0)
  91. #Generate input and output nodes
  92. var effect: GraphNode = Nodes.get_node(NodePath("inputfile")).duplicate()
  93. effect.name = "inputfile"
  94. get_node("GraphEdit").add_child(effect, true)
  95. effect.connect("open_help", Callable(open_help, "show_help_for_node"))
  96. effect.position_offset = Vector2(20,80)
  97. effect = Nodes.get_node(NodePath("outputfile")).duplicate()
  98. effect.name = "outputfile"
  99. get_node("GraphEdit").add_child(effect, true)
  100. effect.connect("open_help", Callable(open_help, "show_help_for_node"))
  101. effect.position_offset = Vector2((DisplayServer.screen_get_size().x - 480) / uiscale, 80)
  102. graph_edit._register_node_movement() #link nodes for tracking position changes for changes tracking
  103. changesmade = false #so it stops trying to save unchanged empty files
  104. get_window().title = "SoundThread"
  105. link_output()
  106. func link_output():
  107. #links various buttons and function in the input nodes - this is called after they are created so that it still works on new and loading files
  108. for control in get_tree().get_nodes_in_group("outputnode"): #check all items in outputnode group
  109. if control.get_meta("outputfunction") == "deleteintermediate": #link delete intermediate files toggle to script
  110. control.toggled.connect(_toggle_delete)
  111. control.button_pressed = true
  112. elif control.get_meta("outputfunction") == "runprocess": #link runprocess button
  113. control.button_down.connect(_run_process)
  114. #elif control.get_meta("outputfunction") == "recycle": #link recycle button
  115. #control.button_down.connect(_recycle_outfile)
  116. elif control.get_meta("outputfunction") == "audioplayer": #link output audio player
  117. output_audio_player = control
  118. elif control.get_meta("outputfunction") == "filename":
  119. control.text = "outfile"
  120. outfilename = control
  121. elif control.get_meta("outputfunction") == "reusefolder":
  122. foldertoggle = control
  123. foldertoggle.button_pressed = true
  124. elif control.get_meta("outputfunction") == "openfolder":
  125. control.button_down.connect(_open_output_folder)
  126. #for control in get_tree().get_nodes_in_group("inputnode"):
  127. #if control.get_meta("inputfunction") == "audioplayer": #link input for recycle function
  128. #print("input player found")
  129. #input_audio_player = control
  130. func check_user_preferences():
  131. var interface_settings = ConfigHandler.load_interface_settings()
  132. var audio_settings = ConfigHandler.load_audio_settings()
  133. var audio_devices = AudioServer.get_output_device_list()
  134. $Console.always_on_top = interface_settings.console_on_top
  135. if audio_devices.has(audio_settings.device):
  136. AudioServer.set_output_device(audio_settings.device)
  137. else:
  138. $AudioDevicePopup.popup_centered()
  139. match interface_settings.theme:
  140. 0:
  141. RenderingServer.set_default_clear_color(Color("#2f4f4e"))
  142. 1:
  143. RenderingServer.set_default_clear_color(Color("#000807"))
  144. 2:
  145. RenderingServer.set_default_clear_color(Color("#98d4d2"))
  146. 3:
  147. RenderingServer.set_default_clear_color(Color(interface_settings.theme_custom_colour))
  148. func show_cdp_location():
  149. $CdpLocationDialog.show()
  150. func check_cdp_location_set():
  151. #checks if the location has been set and prompts user to set it
  152. var cdpprogs_settings = ConfigHandler.load_cdpprogs_settings()
  153. if cdpprogs_settings.location == "no_location":
  154. $NoLocationPopup.popup_centered()
  155. else:
  156. #if location is set, stores it in a variable
  157. cdpprogs_location = str(cdpprogs_settings.location)
  158. print(cdpprogs_location)
  159. func _on_ok_button_button_down() -> void:
  160. #after user has read dialog on where to find cdp progs this loads the file browser
  161. $NoLocationPopup.hide()
  162. if OS.get_name() == "Windows":
  163. $CdpLocationDialog.current_dir = "C:/"
  164. else:
  165. $CdpLocationDialog.current_dir = OS.get_environment("HOME")
  166. $CdpLocationDialog.show()
  167. func _on_cdp_location_dialog_dir_selected(dir: String) -> void:
  168. #saves default location for cdp programs in config file
  169. ConfigHandler.save_cdpprogs_settings(dir)
  170. cdpprogs_location = dir
  171. func _on_cdp_location_dialog_canceled() -> void:
  172. #cycles around the set location prompt if user cancels the file dialog
  173. check_cdp_location_set()
  174. func _input(event):
  175. if event.is_action_pressed("copy_node"):
  176. graph_edit.copy_selected_nodes()
  177. get_viewport().set_input_as_handled()
  178. elif event.is_action_pressed("paste_node"):
  179. simulate_mouse_click() #hacky fix to stop tooltips getting stuck
  180. await get_tree().process_frame
  181. graph_edit.paste_copied_nodes()
  182. get_viewport().set_input_as_handled()
  183. elif event.is_action_pressed("undo"):
  184. undo_redo.undo()
  185. elif event.is_action_pressed("redo"):
  186. undo_redo.redo()
  187. elif event.is_action_pressed("save"):
  188. if currentfile == "none":
  189. savestate = "saveas"
  190. $SaveDialog.popup_centered()
  191. else:
  192. save_load.save_graph_edit(currentfile)
  193. elif event.is_action_pressed("open_explore"):
  194. open_explore()
  195. func simulate_mouse_click():
  196. #simulates clicking the middle mouse button in order to hide any visible tooltips
  197. var click_pos = get_viewport().get_mouse_position()
  198. var down_event := InputEventMouseButton.new()
  199. down_event.button_index = MOUSE_BUTTON_MIDDLE
  200. down_event.pressed = true
  201. down_event.position = click_pos
  202. Input.parse_input_event(down_event)
  203. var up_event := InputEventMouseButton.new()
  204. up_event.button_index = MOUSE_BUTTON_MIDDLE
  205. up_event.pressed = false
  206. up_event.position = click_pos
  207. Input.parse_input_event(up_event)
  208. func _run_process() -> void:
  209. #check if any of the inputfile nodes don't have files loaded
  210. for node in graph_edit.get_children():
  211. if node.get_meta("command") == "inputfile" and node.get_node("AudioPlayer").has_meta("inputfile") == false:
  212. $NoInputPopup.popup_centered()
  213. return
  214. #check if the reuse folder toggle is set and a folder has been previously chosen
  215. if foldertoggle.button_pressed == true and lastoutputfolder != "none":
  216. _on_file_dialog_dir_selected(lastoutputfolder)
  217. else:
  218. $FileDialog.show()
  219. func _on_file_dialog_dir_selected(dir: String) -> void:
  220. lastoutputfolder = dir
  221. console_output.clear()
  222. var interface_settings = ConfigHandler.load_interface_settings()
  223. if interface_settings.disable_progress_bar == false:
  224. $ProgressWindow.show()
  225. else:
  226. if $Console.is_visible():
  227. $Console.hide()
  228. await get_tree().process_frame # Wait a frame to allow hide to complete
  229. $Console.popup_centered()
  230. else:
  231. $Console.popup_centered()
  232. await get_tree().process_frame
  233. run_thread.log_console("Generating processing queue", true)
  234. await get_tree().process_frame
  235. #get the current time in hh-mm-ss format as default : causes file name issues
  236. var time_dict = Time.get_time_dict_from_system()
  237. # Pad with zeros to ensure two digits for hour, minute, second
  238. var hour = str(time_dict.hour).pad_zeros(2)
  239. var minute = str(time_dict.minute).pad_zeros(2)
  240. var second = str(time_dict.second).pad_zeros(2)
  241. var time_str = hour + "-" + minute + "-" + second
  242. Global.outfile = dir + "/" + outfilename.text.get_basename() + "_" + Time.get_date_string_from_system() + "_" + time_str
  243. run_thread.log_console("Output directory and file name(s):" + Global.outfile, true)
  244. await get_tree().process_frame
  245. run_thread.run_thread_with_branches()
  246. func _toggle_delete(toggled_on: bool):
  247. delete_intermediate_outputs = toggled_on
  248. print(toggled_on)
  249. func _on_console_close_requested() -> void:
  250. $Console.hide()
  251. func _on_console_open_folder_button_down() -> void:
  252. $Console.hide()
  253. OS.shell_open(Global.outfile.get_base_dir())
  254. func _on_ok_button_2_button_down() -> void:
  255. $NoInputPopup.hide()
  256. func _on_ok_button_3_button_down() -> void:
  257. $MultipleConnectionsPopup.hide()
  258. func _on_settings_button_index_pressed(index: int) -> void:
  259. var interface_settings = ConfigHandler.load_interface_settings()
  260. match index:
  261. 0:
  262. $Settings.popup_centered()
  263. 1:
  264. $AudioSettings.popup_centered()
  265. 2:
  266. if $Console.is_visible():
  267. $Console.hide()
  268. await get_tree().process_frame # Wait a frame to allow hide to complete
  269. $Console.popup_centered()
  270. else:
  271. $Console.popup_centered()
  272. func _on_file_button_index_pressed(index: int) -> void:
  273. match index:
  274. 0:
  275. if changesmade == true:
  276. savestate = "newfile"
  277. $SaveChangesPopup.popup_centered()
  278. else:
  279. new_patch()
  280. currentfile = "none" #reset current file to none for save tracking
  281. print("new patch, changes made =")
  282. print(changesmade)
  283. print("current file =")
  284. print(currentfile)
  285. 1:
  286. if currentfile == "none":
  287. savestate = "saveas"
  288. $SaveDialog.popup_centered()
  289. else:
  290. save_load.save_graph_edit(currentfile)
  291. print("save pressed, changes made =")
  292. print(changesmade)
  293. print("current file =")
  294. print(currentfile)
  295. 2:
  296. savestate = "saveas"
  297. $SaveDialog.popup_centered()
  298. 3:
  299. if changesmade == true:
  300. savestate = "load"
  301. $SaveChangesPopup.popup_centered()
  302. else:
  303. $LoadDialog.popup_centered()
  304. func _on_save_dialog_file_selected(path: String) -> void:
  305. save_load.save_graph_edit(path) #save file
  306. #check what the user was trying to do before save and do that action
  307. if savestate == "newfile":
  308. new_patch()
  309. currentfile = "none" #reset current file to none for save tracking
  310. elif savestate == "load":
  311. $LoadDialog.popup_centered()
  312. elif savestate == "helpfile":
  313. currentfile = "none" #reset current file to none for save tracking so user cant save over help file
  314. save_load.load_graph_edit(helpfile)
  315. elif savestate == "quit":
  316. await get_tree().create_timer(0.25).timeout #little pause so that it feels like it actually saved even though it did
  317. get_tree().quit()
  318. elif savestate == "saveas":
  319. currentfile = path
  320. savestate = "none" #reset save state, not really needed but feels good
  321. func _on_load_dialog_file_selected(path: String) -> void:
  322. currentfile = path #tracking path here only means "save" only saves patches the user has loaded rather than overwriting help files
  323. save_load.load_graph_edit(path)
  324. func _on_help_button_index_pressed(index: int) -> void:
  325. match index:
  326. 0:
  327. pass
  328. 1:
  329. if changesmade == true:
  330. savestate = "helpfile"
  331. helpfile = "res://examples/getting_started.thd"
  332. $SaveChangesPopup.popup_centered()
  333. else:
  334. currentfile = "none" #reset current file to none for save tracking so user cant save over help file
  335. save_load.load_graph_edit("res://examples/getting_started.thd")
  336. 2:
  337. if changesmade == true:
  338. savestate = "helpfile"
  339. helpfile = "res://examples/navigating.thd"
  340. $SaveChangesPopup.popup_centered()
  341. else:
  342. currentfile = "none" #reset current file to none for save tracking so user cant save over help file
  343. save_load.load_graph_edit("res://examples/navigating.thd")
  344. 3:
  345. if changesmade == true:
  346. savestate = "helpfile"
  347. helpfile = "res://examples/building_a_thread.thd"
  348. $SaveChangesPopup.popup_centered()
  349. else:
  350. currentfile = "none" #reset current file to none for save tracking so user cant save over help file
  351. save_load.load_graph_edit("res://examples/building_a_thread.thd")
  352. 4:
  353. if changesmade == true:
  354. savestate = "helpfile"
  355. helpfile = "res://examples/frequency_domain.thd"
  356. $SaveChangesPopup.popup_centered()
  357. else:
  358. currentfile = "none" #reset current file to none for save tracking so user cant save over help file
  359. save_load.load_graph_edit("res://examples/frequency_domain.thd")
  360. 5:
  361. if changesmade == true:
  362. savestate = "helpfile"
  363. helpfile = "res://examples/automation.thd"
  364. $SaveChangesPopup.popup_centered()
  365. else:
  366. currentfile = "none" #reset current file to none for save tracking so user cant save over help file
  367. save_load.load_graph_edit("res://examples/automation.thd")
  368. 6:
  369. if changesmade == true:
  370. savestate = "helpfile"
  371. helpfile = "res://examples/trimming.thd"
  372. $SaveChangesPopup.popup_centered()
  373. else:
  374. currentfile = "none" #reset current file to none for save tracking so user cant save over help file
  375. save_load.load_graph_edit("res://examples/trimming.thd")
  376. 7:
  377. pass
  378. 8:
  379. if changesmade == true:
  380. savestate = "helpfile"
  381. helpfile = "res://examples/wetdry.thd"
  382. $SaveChangesPopup.popup_centered()
  383. else:
  384. currentfile = "none" #reset current file to none for save tracking so user cant save over help file
  385. save_load.load_graph_edit("res://examples/wetdry.thd")
  386. 9:
  387. if changesmade == true:
  388. savestate = "helpfile"
  389. helpfile = "res://examples/resonant_filters.thd"
  390. $SaveChangesPopup.popup_centered()
  391. else:
  392. currentfile = "none" #reset current file to none for save tracking so user cant save over help file
  393. save_load.load_graph_edit("res://examples/resonant_filters.thd")
  394. 10:
  395. pass
  396. 11:
  397. OS.shell_open("https://www.composersdesktop.com/docs/html/ccdpndex.htm")
  398. 12:
  399. OS.shell_open("https://github.com/j-p-higgins/SoundThread/issues")
  400. #func _recycle_outfile():
  401. #if outfile != "no file":
  402. #input_audio_player.recycle_outfile(outfile)
  403. func _on_save_changes_button_down() -> void:
  404. $SaveChangesPopup.hide()
  405. if currentfile == "none":
  406. $SaveDialog.show()
  407. else:
  408. save_load.save_graph_edit(currentfile)
  409. if savestate == "newfile":
  410. new_patch()
  411. currentfile = "none" #reset current file to none for save tracking
  412. elif savestate == "load":
  413. $LoadDialog.popup_centered()
  414. elif savestate == "helpfile":
  415. currentfile = "none" #reset current file to none for save tracking so user cant save over help file
  416. save_load.load_graph_edit(helpfile)
  417. elif savestate == "quit":
  418. await get_tree().create_timer(0.25).timeout #little pause so that it feels like it actually saved even though it did
  419. get_tree().quit()
  420. savestate = "none"
  421. func _on_dont_save_changes_button_down() -> void:
  422. $SaveChangesPopup.hide()
  423. if savestate == "newfile":
  424. new_patch()
  425. currentfile = "none" #reset current file to none for save tracking
  426. elif savestate == "load":
  427. $LoadDialog.popup_centered()
  428. elif savestate == "helpfile":
  429. currentfile = "none" #reset current file to none for save tracking so user cant save over help file
  430. save_load.load_graph_edit(helpfile)
  431. elif savestate == "quit":
  432. get_tree().quit()
  433. savestate = "none"
  434. func _notification(what):
  435. if what == NOTIFICATION_WM_CLOSE_REQUEST:
  436. run_thread._on_kill_process_button_down()
  437. $Console.hide()
  438. if changesmade == true:
  439. savestate = "quit"
  440. $SaveChangesPopup.popup_centered()
  441. #$HelpWindow.hide()
  442. else:
  443. get_tree().quit() # default behavior
  444. func _open_output_folder():
  445. if lastoutputfolder != "none":
  446. OS.shell_open(lastoutputfolder)
  447. func _on_rich_text_label_meta_clicked(meta: Variant) -> void:
  448. print(str(meta))
  449. OS.shell_open(str(meta))
  450. func _on_graph_edit_popup_request(at_position: Vector2) -> void:
  451. effect_position = graph_edit.get_local_mouse_position()
  452. #get the mouse position in screen coordinates
  453. var mouse_screen_pos = DisplayServer.mouse_get_position()
  454. #get the window position in screen coordinates
  455. var window_screen_pos = get_window().position
  456. #get the window size relative to its scaling for retina displays
  457. var window_size = get_window().size * DisplayServer.screen_get_scale()
  458. #calculate the xy position of the mouse clamped to the size of the window and menu so it doesn't go off the screen
  459. var clamped_x = clamp(mouse_screen_pos.x, window_screen_pos.x, window_screen_pos.x + window_size.x - $SearchMenu.size.x)
  460. var clamped_y = clamp(mouse_screen_pos.y, window_screen_pos.y, window_screen_pos.y + window_size.y - (420 * DisplayServer.screen_get_scale()))
  461. #position and show the menu
  462. $SearchMenu.position = Vector2(clamped_x, clamped_y)
  463. $SearchMenu.popup()
  464. func _on_audio_settings_close_requested() -> void:
  465. $AudioSettings.hide()
  466. func _on_open_audio_settings_button_down() -> void:
  467. $AudioDevicePopup.hide()
  468. $AudioSettings.popup_centered()
  469. func _on_audio_device_popup_close_requested() -> void:
  470. $AudioDevicePopup.hide()
  471. func _on_mainmenu_close_requested() -> void:
  472. #closes menu if click is anywhere other than the menu as it is a window with popup set to true
  473. $mainmenu.hide()
  474. func open_explore():
  475. effect_position = graph_edit.get_local_mouse_position()
  476. #get the mouse position in screen coordinates
  477. var mouse_screen_pos = DisplayServer.mouse_get_position()
  478. #get the window position in screen coordinates
  479. var window_screen_pos = get_window().position
  480. #get the window size relative to its scaling for retina displays
  481. var window_size = get_window().size * DisplayServer.screen_get_scale()
  482. #get the size of the popup menu
  483. var popup_size = $mainmenu.size
  484. #calculate the xy position of the mouse clamped to the size of the window and menu so it doesn't go off the screen
  485. var clamped_x = clamp(mouse_screen_pos.x, window_screen_pos.x, window_screen_pos.x + window_size.x - popup_size.x)
  486. var clamped_y = clamp(mouse_screen_pos.y, window_screen_pos.y, window_screen_pos.y + window_size.y - popup_size.y)
  487. #position and show the menu
  488. $mainmenu.position = Vector2(clamped_x, clamped_y)
  489. $mainmenu.popup()
  490. func change_console_settings(toggled: bool):
  491. $Console.always_on_top = toggled
  492. func _on_kill_process_button_down() -> void:
  493. run_thread._on_kill_process_button_down()