extends Control const NO_SUB = "No new submissions. " const SEARCH_TEMPLATE = "https://www.furaffinity.net/search/?q=%s&order-by=date" var FA = FAParser.new() onready var grid:Container = get_node("%ThumbGrid") var downloaded_panel = preload("res://theme_panels/downloaded.tres") var countdown:bool = false var stuff_loaded:int = 0 var stuff_requested:int = 0 #var sub_sata:Dictionary #var viewer:PackedScene = preload("res://SubViewer.tscn") #var current_viewer:Control func _ready(): #$GalleryGather.gather(Global.watchs.split(" ",false)) # this is for grabbing the watches but might put it elsewhere clear_grid() var urls:PoolStringArray = [] for user in Settings.settings.Watches: var userurl:String = user.replace("_","").to_lower() if Settings.settings.ShowGallery: urls.append("/gallery/%s"%[userurl]) if Settings.settings.ShowScraps: urls.append("/scraps/%s"%[userurl]) if Settings.settings.ShowFavorites: urls.append("/favorites/%s"%[userurl]) for search in Settings.settings.Searches: urls.append(SEARCH_TEMPLATE%[search]) $GalleryGather.pages = urls $GalleryGather.gather(Settings.settings.LastID) func _on_GalleryGather_GatheringComplete(data:Dictionary): var ids = data.keys() # ids.sort() ids.sort_custom(Sorter,"sort_descending") print("loading ",ids.size()," submissions...") $"%Loading".max_value = ids.size() for i in ids: if i > Global.lastid and grid.get_node_or_null(str(i)) == null: Global.stuff_requested += 1 var e:SubEntry = Global.sub_entry.instance() e.SubData = data[i] e.name = str(i) grid.add_child(e) #e.get_node("%img").connect("gui_input",self,"preview",[i]) e.get_node("%Icon").connect("pressed",self,"open_preview",[i]) $"%Nuke".disabled = false if grid.get_child_count() == 0 and Settings.settings.ReloadInt > 0: $RefTimer.start(Settings.settings.ReloadInt) countdown = true else: $"%LoadStatus".text = "Found %d submissions."%[Global.stuff_requested] if not OS.is_window_focused(): OS.request_attention() #maybe also play a sound class Sorter: static func sort_descending(a, b): if a > b: return true return false func _on_Setting_pressed(): Global.stuff_loaded = 0 Global.stuff_requested = 0 get_tree().change_scene("res://settings.tscn") func _on_sizeSlider_value_changed(value:int): Global.sub_size = value for i in grid.get_children(): if i is Control: i.rect_min_size = Vector2(value,value+64) func preview(event:InputEvent,id:int): # open the submission in the preview thing if ( (event.is_action_pressed("click")) or (event is InputEventScreenTouch and event.is_pressed()) ): open_preview(id) func open_preview(id:int): if is_instance_valid(Global.current_viewer): if Global.current_viewer.id == id: return else: Global.current_viewer.queue_free() Global.current_viewer = Global.viewer.instance() Global.current_viewer.id = id $"%ViewSplit".add_child(Global.current_viewer) Global.current_viewer.connect("downloaded",self,"downloaded") func downloaded(id): var node:SubEntry = $"%ThumbGrid".get_node_or_null(str(id)) if node != null: node.downloaded() if not id in History.data: History.add(id) func _on_Nuke_pressed(): $RefTimer.stop() Global.clear_cache() Global.stuff_loaded = 0 Global.stuff_requested = 0 if grid.get_child_count() > 0: var last_id = grid.get_child(0).name.to_int() Settings.settings.LastID = last_id Settings.save_profile() Global.lastid = last_id for i in grid.get_children(): i.queue_free() _ready() $"%Nuke".disabled = true countdown = false func _process(_delta): if countdown: $"%LoadStatus".text = "No new submissions. Rechecking in %d minutes"%[ int($RefTimer.time_left / 60) + 1 ] func clear_grid(): for i in grid.get_children(): i.queue_free() $GalleryGather.sub_data = {} Global.busy = 0 #Global.stuff_loaded = 0 func gather(pages:PoolStringArray,least_id:int = 0): clear_grid() $GalleryGather.pages = pages $GalleryGather.gather(least_id)