From b71b55c7e048216d720a8e3efa0a8cc19a7f5555 Mon Sep 17 00:00:00 2001 From: "Jeison Yehuda Amihud (Blender Dumbass)" Date: Mon, 10 May 2021 19:58:11 +0000 Subject: [PATCH] Implementing Error Catching System --- studio/studio_gtk.py | 399 ++++++++++++++++++++++--------------------- 1 file changed, 205 insertions(+), 194 deletions(-) diff --git a/studio/studio_gtk.py b/studio/studio_gtk.py index 8a0ebf9..fa0c598 100644 --- a/studio/studio_gtk.py +++ b/studio/studio_gtk.py @@ -29,6 +29,8 @@ from studio import studio_analyticsLayer from studio import studio_scriptLayer from studio import studio_multiuserLayer +from troubleshooter import error_notify + # UI modules from UI import UI_testing from UI import UI_color @@ -58,7 +60,9 @@ def run(project, win): win.destroy() except: pass - + + + # Setting up the window win = Gtk.Window() win.maximize() @@ -209,204 +213,211 @@ def pmdrawing(pmdrawing, main_layer, win): # a bit simpler then making some kind of dynamic draw call system that might # be used in such an application. But to hell with it. I did the same on the # Blender-Organizer altho with way less cairo. And it works well enought. - - # FPS counter - win.fFPS = datetime.datetime.now() - win.tFPS = win.fFPS - win.sFPS - - if win.current["frame"] % 5 == 0: - win.blink = not win.blink # Iterating the blink - - if win.current["frame"] % 10 == 0: - win.FPS = int ( 1.0 / ( win.tFPS.microseconds /1000000)) - - if "Auto_De-Blur" not in win.settings: - win.settings["Auto_De-Blur"] = True - - # Fail switch for Graphics. - if win.FPS < 10 and win.settings["Auto_De-Blur"]: - win.settings["Blur"] = False - - win.sFPS = datetime.datetime.now() - - # Current frame (for animations and things like this) - win.current["frame"] += 1 - - # Getting data about the frame - win.current['mx'] = win.get_pointer()[0] - win.current['my'] = win.get_pointer()[1] - win.current['w'] = win.get_size()[0] - win.current['h'] = win.get_size()[1] - - - win.cursors = { - "arrow":Gdk.Cursor.new(Gdk.CursorType.ARROW), - "watch":Gdk.Cursor.new(Gdk.CursorType.WATCH), - "text" :Gdk.Cursor.new(Gdk.CursorType.XTERM), - "hand" :Gdk.Cursor.new(Gdk.CursorType.HAND1), - "cross":Gdk.Cursor.new(Gdk.CursorType.CROSS) - } - win.current["cursor"] = win.cursors["arrow"] - - # Attemt to make things straight when pressing Ctrl. - if 65507 in win.current["keys"] and win.current["LMB"]: - - # Let's see what's got more distance. X or Y motion of the mouse. - - dx = win.current["LMB"][0] - win.current["mx"] - dx = max(dx, dx*-1) - dy = win.current["LMB"][1] - win.current["my"] - dy = max(dy, dy*-1) - - # If X has more ditance. Then Y should be the same as begining. - - if dx > dy: - win.current["my"] = win.current["LMB"][1] - else: - win.current["mx"] = win.current["LMB"][0] - - # Attempt at making the mouse cursor a bit more usefull for stuff. - if win.previous["LMB"] and len(win.previous["LMB"]) > 2 and win.current["LMB"]: - win.current["LMB"] = win.previous["LMB"] - - #Background color - UI_color.set(main_layer, win, "background") - main_layer.rectangle( - 0, - 0, - win.current['w'], - win.current['h']) - main_layer.fill() - - # Tooltips and other junk has to be defined here. And then drawn later to - # the screen. So here we get a special layer. That will be drawn to during - # the time of drawing. And later composeted over everything. - - win.tooltip_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, win.current['w'], - win.current['h']) - win.tooltip = cairo.Context(win.tooltip_surface) - win.tooltip.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL) - - - # Layers. Order of them matter - Layers = [] - - if win.url == "story_editor": - Layers.append([studio_storyLayer.layer(win),"story_editor"]) - if "story_editor" in win.layercashe: - del win.layercashe["story_editor"] - else: - if "story_editor" not in win.layercashe: - win.layercashe["story_editor" ] = studio_storyLayer.layer(win) - - Layers.append([win.layercashe["story_editor" ],"story_editor"]) - - if win.url == "story_deletion_dialog": - Layers.append([studio_storyDeletionLayer.layer(win),"story_deletion_dialog"]) - - elif win.url == "settings_layer": - Layers.append([studio_settingsLayer.layer(win),"settings_layer"]) - - elif win.url == "analytics": - Layers.append([studio_analyticsLayer.layer(win),"analytics"]) - - elif win.url == "assets": - Layers.append([studio_assetLayer.layer(win),"assets"]) - - elif win.url == "script": - Layers.append([studio_scriptLayer.layer(win), "script"]) - - elif win.url == "multiuser": - Layers.append([studio_multiuserLayer.layer(win), "multiuser"]) - - # Call layers. See studio/studio_dialogs.py for explanation. It's wild. - - win.calllayer = False - remlater = [] - - for call in list(win.current["calls"].keys()): - - if win.current["calls"][call]["var"] == None: - Layers.append([win.current["calls"][call]["draw"](win, call)]) - win.url = win.current["calls"][call]["url"] - win.calllayer = True - - else: - win.url = win.current["calls"][call]["back"] - win.current["calls"][call]["call"](win, win.current["calls"][call]["var"]) - win.textactive = "" - remlater.append(call) - for call in remlater: + try: - del win.current["calls"][call] - - - - Layers.append([UI_testing.layer(win)]) - Layers.append([win.tooltip_surface]) - - # Combining layers - for layer in Layers: - if len(layer) > 1: - layer, url = layer - blur = UI_elements.animate(url+"_blur", win, 50) - if (win.url != url or win.calllayer): - if win.current["tool"] not in ["schedule", "grab"]: - blur = UI_elements.animate(url+"_blur", win, blur, 50, 2, True) - else: - blur = UI_elements.animate(url+"_blur", win, 50, 50, 0, True) + + # FPS counter + win.fFPS = datetime.datetime.now() + win.tFPS = win.fFPS - win.sFPS + + if win.current["frame"] % 5 == 0: + win.blink = not win.blink # Iterating the blink + + if win.current["frame"] % 10 == 0: + win.FPS = int ( 1.0 / ( win.tFPS.microseconds /1000000)) + + if "Auto_De-Blur" not in win.settings: + win.settings["Auto_De-Blur"] = True + + # Fail switch for Graphics. + if win.FPS < 10 and win.settings["Auto_De-Blur"]: + win.settings["Blur"] = False + + win.sFPS = datetime.datetime.now() + + # Current frame (for animations and things like this) + win.current["frame"] += 1 + + # Getting data about the frame + win.current['mx'] = win.get_pointer()[0] + win.current['my'] = win.get_pointer()[1] + win.current['w'] = win.get_size()[0] + win.current['h'] = win.get_size()[1] + + + win.cursors = { + "arrow":Gdk.Cursor.new(Gdk.CursorType.ARROW), + "watch":Gdk.Cursor.new(Gdk.CursorType.WATCH), + "text" :Gdk.Cursor.new(Gdk.CursorType.XTERM), + "hand" :Gdk.Cursor.new(Gdk.CursorType.HAND1), + "cross":Gdk.Cursor.new(Gdk.CursorType.CROSS) + } + win.current["cursor"] = win.cursors["arrow"] + + # Attemt to make things straight when pressing Ctrl. + if 65507 in win.current["keys"] and win.current["LMB"]: + + # Let's see what's got more distance. X or Y motion of the mouse. + + dx = win.current["LMB"][0] - win.current["mx"] + dx = max(dx, dx*-1) + dy = win.current["LMB"][1] - win.current["my"] + dy = max(dy, dy*-1) + + # If X has more ditance. Then Y should be the same as begining. + + if dx > dy: + win.current["my"] = win.current["LMB"][1] else: - if win.current["tool"] not in ["schedule", "grab"]: - blur = UI_elements.animate(url+"_blur", win, blur, 0, 2, True) - else: - blur = UI_elements.animate(url+"_blur", win, 0, 0, 0, True) - layer = UI_elements.blur(layer, win, blur) + win.current["mx"] = win.current["LMB"][0] + + # Attempt at making the mouse cursor a bit more usefull for stuff. + if win.previous["LMB"] and len(win.previous["LMB"]) > 2 and win.current["LMB"]: + win.current["LMB"] = win.previous["LMB"] + + #Background color + UI_color.set(main_layer, win, "background") + main_layer.rectangle( + 0, + 0, + win.current['w'], + win.current['h']) + main_layer.fill() + + # Tooltips and other junk has to be defined here. And then drawn later to + # the screen. So here we get a special layer. That will be drawn to during + # the time of drawing. And later composeted over everything. + + win.tooltip_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, win.current['w'], + win.current['h']) + win.tooltip = cairo.Context(win.tooltip_surface) + win.tooltip.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL) + + + # Layers. Order of them matter + Layers = [] + + if win.url == "story_editor": + Layers.append([studio_storyLayer.layer(win),"story_editor"]) + if "story_editor" in win.layercashe: + del win.layercashe["story_editor"] else: - layer = layer[0] - main_layer.set_source_surface(layer, 0 , 0) - main_layer.paint() - - - win.get_root_window().set_cursor(win.current["cursor"]) - - # If you press ESC you get back from any window to the main menu. - if 65307 in win.current["keys"] and win.url != "install_updates": - win.url = "story_editor" - win.story["selected"] = [] - win.current["tool"] = "selection" - win.current["keys"] = [] - win.textactive = "" - - # For the rendering I will need to read render info at each frame and parse - # it in various windows. - - network_renders.read_renders(win) - + if "story_editor" not in win.layercashe: + win.layercashe["story_editor" ] = studio_storyLayer.layer(win) + + Layers.append([win.layercashe["story_editor" ],"story_editor"]) + + if win.url == "story_deletion_dialog": + Layers.append([studio_storyDeletionLayer.layer(win),"story_deletion_dialog"]) + + elif win.url == "settings_layer": + Layers.append([studio_settingsLayer.layer(win),"settings_layer"]) + + elif win.url == "analytics": + Layers.append([studio_analyticsLayer.layer(win),"analytics"]) + + elif win.url == "assets": + Layers.append([studio_assetLayer.layer(win),"assets"]) + + elif win.url == "script": + Layers.append([studio_scriptLayer.layer(win), "script"]) + + elif win.url == "multiuser": + Layers.append([studio_multiuserLayer.layer(win), "multiuser"]) + + # Call layers. See studio/studio_dialogs.py for explanation. It's wild. + + win.calllayer = False + remlater = [] + + for call in list(win.current["calls"].keys()): + + if win.current["calls"][call]["var"] == None: + Layers.append([win.current["calls"][call]["draw"](win, call)]) + win.url = win.current["calls"][call]["url"] + win.calllayer = True + + else: + win.url = win.current["calls"][call]["back"] + win.current["calls"][call]["call"](win, win.current["calls"][call]["var"]) + win.textactive = "" + remlater.append(call) + + for call in remlater: + + del win.current["calls"][call] + + + + Layers.append([UI_testing.layer(win)]) + Layers.append([win.tooltip_surface]) + + # Combining layers + for layer in Layers: + if len(layer) > 1: + layer, url = layer + blur = UI_elements.animate(url+"_blur", win, 50) + if (win.url != url or win.calllayer): + if win.current["tool"] not in ["schedule", "grab"]: + blur = UI_elements.animate(url+"_blur", win, blur, 50, 2, True) + else: + blur = UI_elements.animate(url+"_blur", win, 50, 50, 0, True) + else: + if win.current["tool"] not in ["schedule", "grab"]: + blur = UI_elements.animate(url+"_blur", win, blur, 0, 2, True) + else: + blur = UI_elements.animate(url+"_blur", win, 0, 0, 0, True) + layer = UI_elements.blur(layer, win, blur) + else: + layer = layer[0] + main_layer.set_source_surface(layer, 0 , 0) + main_layer.paint() + + + win.get_root_window().set_cursor(win.current["cursor"]) + + # If you press ESC you get back from any window to the main menu. + if 65307 in win.current["keys"] and win.url != "install_updates": + win.url = "story_editor" + win.story["selected"] = [] + win.current["tool"] = "selection" + win.current["keys"] = [] + win.textactive = "" + + + # For the rendering I will need to read render info at each frame and parse + # it in various windows. + + network_renders.read_renders(win) + + + # There is a but in the Gnome I guess. That autopresses the Shift and Ctrl + # keys when you scroll to different windows. So here is a little fix. + if not win.is_active(): + win.current["keys"] = [] + + elif "is_active" in win.previous and not win.previous["is_active"]: + win.multiuser["last_request"] = "" + UI_elements.reload_images(win) + + win.current["is_active"] = win.is_active() + + # Saving data about this frame for the next one. A bit hard to get WTF am I + # doing here. Basically trying to avoid current and previous data to be links + # of the same data. + + previous(win) # Moved it into a seprate function for obvoius reasons + + # Refreshing those that need to be refrashed + win.current["scroll"] = [0,0] + + # Refreshing the frame automatically + pmdrawing.queue_draw() + except: + Gtk.main_quit() + error_notify.show() - # There is a but in the Gnome I guess. That autopresses the Shift and Ctrl - # keys when you scroll to different windows. So here is a little fix. - if not win.is_active(): - win.current["keys"] = [] - - elif "is_active" in win.previous and not win.previous["is_active"]: - win.multiuser["last_request"] = "" - UI_elements.reload_images(win) - - win.current["is_active"] = win.is_active() - - # Saving data about this frame for the next one. A bit hard to get WTF am I - # doing here. Basically trying to avoid current and previous data to be links - # of the same data. - - previous(win) # Moved it into a seprate function for obvoius reasons - - # Refreshing those that need to be refrashed - win.current["scroll"] = [0,0] - - # Refreshing the frame automatically - pmdrawing.queue_draw() - # This program will have things like mouse and keyboard input. And this setup # Will be done in both PM and the actuall Project window. ( Also in the render