From 31b6d2fb37d7c73938fb64c85bf89441eaf22cb3 Mon Sep 17 00:00:00 2001 From: Victorious Children Studios Date: Tue, 19 Dec 2023 19:32:02 +0200 Subject: [PATCH] It works!!! ( Early Alpha ) --- network/http_client.py | 59 ++++++++++++++++++++++----------- settings/languages/English.data | 3 +- studio/studio_assetLayer.py | 2 +- studio/studio_scriptLayer.py | 2 +- studio/studio_storyLayer.py | 13 +++++++- studio/studio_vseLayer.py | 47 +++++++++++++++++++++++++- 6 files changed, 101 insertions(+), 25 deletions(-) diff --git a/network/http_client.py b/network/http_client.py index 6c9539d..66fd97d 100644 --- a/network/http_client.py +++ b/network/http_client.py @@ -145,9 +145,14 @@ def get_folder_info(win, folders, cur): win.current["remote-folder-data"][cur] = {"missing":{}, "changed":{}} - def sort_file(filename, files, f): - filedata = files.get(f, {}) - filedata["finished"] = False + win.current["remote-folder-data"][cur]["loaded"] = False + + def sort_file(filename, files, f, filedata=None): + + if not filedata: + filedata = files.get(f, {}) + filedata["finished"] = False + try: hashis = hashlib.md5(open(win.project+filename,'rb').read()).hexdigest() except: @@ -201,12 +206,15 @@ def get_folder_info(win, folders, cur): while nc: try: dp = go(win, website, "/blend"+nc) - + + for f in dp.get("files", {}): + try: sort_file(f, dp.get("files", {}), - f[f.rfind("/")+1:]) + f[f.rfind("/")+1:], + filedata=dp.get("files", {})[f]) except Exception as e: print(e) except Exception as e: @@ -221,6 +229,8 @@ def get_folder_info(win, folders, cur): for i in win.current["remote-folder-data"][cur][t]: print(" "+i) + win.current["remote-folder-data"][cur]["loaded"] = True + def get_folders(win): # This function will get specified subfolders @@ -568,24 +578,33 @@ def prompt_layer(win, call): tip=talk.text("cancel")) # Download button - def do(): - win.current["remote-folder-data"][cur]["downloading"] = True - start_downaloding = threading.Thread(target=download_missing_changed, - args=(win, cur, )) - start_downaloding.setDaemon(True) - start_downaloding.start() + if win.current["remote-folder-data"][cur]["loaded"]: + + def do(): + win.current["remote-folder-data"][cur]["downloading"] = True + + start_downaloding = threading.Thread(target=download_missing_changed, + args=(win, cur, )) + start_downaloding.setDaemon(True) + start_downaloding.start() - UI_elements.roundrect(layer, win, - win.current["w"]/2+270, - win.current["h"]-140, - 40, - 40, - 10, - button=do, - icon="download", - tip=talk.text("DownloadRemoteServer")) + UI_elements.roundrect(layer, win, + win.current["w"]/2+270, + win.current["h"]-140, + 40, + 40, + 10, + button=do, + icon="download", + tip=talk.text("DownloadRemoteServer")) + else: + UI_color.set(layer, win, "text_normal") + layer.set_font_size(15) + layer.move_to(win.current["w"]/2, + win.current["h"]-120,) + layer.show_text(talk.text("StillLoadingRemoteData")) else: diff --git a/settings/languages/English.data b/settings/languages/English.data index dd20793..5b23837 100644 --- a/settings/languages/English.data +++ b/settings/languages/English.data @@ -290,4 +290,5 @@ ChangedFiles = [Changed Files] RemoteAssetUpdates = [Remote Asset Updates] RemoteShotUpdates = [Remote Shot Updates] DownloadRemoteServer = [Download Files] -blender-bash = [Command To Start Blender] \ No newline at end of file +blender-bash = [Command To Start Blender] +StillLoadingRemoteData = [Still Loading ...] \ No newline at end of file diff --git a/studio/studio_assetLayer.py b/studio/studio_assetLayer.py index 5a37dd1..f645fad 100644 --- a/studio/studio_assetLayer.py +++ b/studio/studio_assetLayer.py @@ -200,7 +200,7 @@ def layer(win): 40, 10, do, - "multiuser", + "download", tip=talk.text("RemoteAssetUpdates")) if win.current["remote-folder-data"][win.cur]["missing"] or win.current["remote-folder-data"][win.cur]["changed"]: diff --git a/studio/studio_scriptLayer.py b/studio/studio_scriptLayer.py index ebb23ca..55cd35e 100644 --- a/studio/studio_scriptLayer.py +++ b/studio/studio_scriptLayer.py @@ -2541,7 +2541,7 @@ def layer(win): 40, 10, button=do, - icon="multiuser", + icon="download", tip=talk.text("RemoteShotUpdates")) diff --git a/studio/studio_storyLayer.py b/studio/studio_storyLayer.py index d3e0ed3..4ee73e4 100644 --- a/studio/studio_storyLayer.py +++ b/studio/studio_storyLayer.py @@ -537,7 +537,18 @@ def layer(win): if var: print(var) oscalls.file_open(win, var) - + # Remote Server Stuff + if win.analytics["from-remote-server"]: + + # Checking date [ FOLDER NAME ] [ FILES TO CHECK FOR ] + check_folders = {"/rnd/" : "*" + } + + check_updates = threading.Thread(target=http_client.get_folder_info, + args=(win, check_folders, "vse", )) + check_updates.setDaemon(True) + check_updates.start() + studio_dialogs.vse(win, "VSEs", after) UI_elements.roundrect(layer, win, diff --git a/studio/studio_vseLayer.py b/studio/studio_vseLayer.py index 80617de..d5d1d99 100644 --- a/studio/studio_vseLayer.py +++ b/studio/studio_vseLayer.py @@ -71,8 +71,53 @@ def layer(win, call): 500, win.current["h"]-200, 10) + + + # Remote server download button - + if win.analytics["from-remote-server"]: + + if "remote-folder-data" not in win.current: + win.current["remote-folder-data"] = {} + + if win.cur not in win.current["remote-folder-data"]: + win.current["remote-folder-data"][win.cur] = {"missing":{}, + "changed":{}} + + def do(): + + def after(win, var): + UI_elements.reload_images(win) + win.current["remote-folder-data"]["prompt"] = "vse" + studio_dialogs.http_client_update_prompt(win, "http-client-prompt", after) + + + UI_elements.roundrect(layer, win, + win.current["w"]/2+210-50, + win.current["h"]-140, + 40, + 40, + 10, + do, + "download", + tip=talk.text("RemoteAssetUpdates")) + + if win.current["remote-folder-data"]["vse"]["missing"] or win.current["remote-folder-data"]["vse"]["changed"]: + count = str(len(win.current["remote-folder-data"]["vse"]["missing"])+len(win.current["remote-folder-data"]["vse"]["changed"])) + UI_color.set(layer, win, "progress_active") + UI_elements.roundrect(layer, win, + win.current["w"]/2+210-50+25, + win.current["h"]-140, + len(count)*12+6, + 25, + 5) + layer.fill() + UI_color.set(layer, win, "text_normal") + layer.set_font_size(20) + layer.move_to(win.current["w"]/2+210-50+28, + win.current["h"]-140+20,) + layer.show_text(count) + # Exit button def do():