FAbrowser/scripts/settings_menu.gd
2024-07-29 19:11:59 -04:00

88 lines
3 KiB
GDScript

extends Control
func _ready():
OS.request_permissions()
Settings.load_profile("user")
if not Settings.settings.PrivacyNoticeConfirmed:
$PrivacyNotice.popup_centered()
Global.busy = 0
$"%Watches".text = PoolStringArray(Settings.settings.Watches).join(" ")
$"%Searches".text = PoolStringArray(Settings.settings.Searches).join("\n")
$"%CookieA".text = Settings.settings.CookieA
$"%CookieB".text = Settings.settings.CookieB
$"%LastID".value = Settings.settings.LastID
$"%ShowGallery".pressed = Settings.settings.ShowGallery
$"%ShowScraps".pressed = Settings.settings.ShowScraps
$"%ShowFavorites".pressed = Settings.settings.ShowFavorites
#$"%OpenWhere".selected = Global.settings.get_value("user","OpenWhere",0)
$"%BlackList".text = PoolStringArray(Settings.settings.BlackList).join("\n")
$"%UserBL".text = PoolStringArray(Settings.settings.UserBL).join(" ")
#Global.blacklist = $"%BlackList".text.split("\n",false)
$"%ReloadInt".value = Settings.settings.ReloadInt / 3600.0
for i in Settings.settings.DownloadDirs.keys():
var dl_dir = Global.dl_dir.instance()
dl_dir.set_data(i,Settings.settings.DownloadDirs[i])
$"%DownloadDirs".add_child(dl_dir)
func _on_SaveButton_pressed():
_on_Apply_pressed()
_on_Cancel_pressed()
func _on_Apply_pressed():
#Global.watchs = $"%Watches".text
Settings.settings.Watches = Array($"%Watches".text.split(" ",false))
Settings.settings.Searches = Array($"%Searches".text.split("\n",false))
Global.headers = PoolStringArray([
"Cookie: a=%s; b=%s"%[$"%CookieA".text,$"%CookieB".text]
])
Settings.settings.CookieA = $"%CookieA".text
Settings.settings.CookieB = $"%CookieB".text
Settings.settings.LastID = int($"%LastID".value)
Global.lastid = int($"%LastID".value)
Settings.settings.ShowGallery = $"%ShowGallery".pressed
Settings.settings.ShowScraps = $"%ShowScraps".pressed
Settings.settings.ShowFavorites = $"%ShowFavorites".pressed
#Global.open_where = $"%OpenWhere".selected
#Global.settings.set_value("user","OpenWhere",$"%OpenWhere".selected)
Settings.settings.BlackList = Array($"%BlackList".text.split("\n",false))
Settings.settings.UserBL = Array($"%UserBL".text.split(" ",false))
Settings.settings.ReloadInt = $"%ReloadInt".value * 3600
#Global.blacklist = $"%BlackList".text.split("\n",false)
Global.stuff_requested = 0
Global.stuff_loaded = 0
var dir_dict:Dictionary = {}
for i in $"%DownloadDirs".get_children():
if not i.is_empty():
dir_dict.merge(i.get_data())
Settings.settings.DownloadDirs = dir_dict
# Save settings to file
Settings.save_profile("user")
func _on_Cancel_pressed():
get_tree().change_scene("res://main.tscn")
func _on_ShowCB_toggled(button_pressed):
$"%CookieA".secret = not button_pressed
$"%CookieB".secret = not button_pressed
func _on_Imp_pressed():
$ImportDialog.popup_centered()
func _on_AddDir_pressed():
var dl_dir = Global.dl_dir.instance()
$"%DownloadDirs".add_child(dl_dir)
# personally i dont like seeing the names of users i dont like.
func _on_ShowBL_toggled(button_pressed):
$"%UserBL".secret = not button_pressed