From e5cfcf326967ccce0e6c8a2fccd459aec136f778 Mon Sep 17 00:00:00 2001 From: "Jeison Yehuda Amihud (Blender Dumbass)" <blenderdumbass@gmail.com> Date: Sun, 6 Dec 2020 13:52:19 +0000 Subject: [PATCH] Upload files to 'studio' --- studio/studio_gtk.py | 10 +- studio/studio_nodes.py | 187 +++++++++++++++++++++++++++++++++--- studio/studio_storyLayer.py | 152 ++++++++++++++++++++++------- 3 files changed, 296 insertions(+), 53 deletions(-) diff --git a/studio/studio_gtk.py b/studio/studio_gtk.py index 70a3151..6358b6a 100644 --- a/studio/studio_gtk.py +++ b/studio/studio_gtk.py @@ -79,7 +79,11 @@ def run(win): win.project = project win.out_dots = {} win.assets = {} - + win.szone = [[100,100],[100,100]] # Square drawn if selected more then one node. + win.surround = { # And this is the list of the squares. Because it's not + "frame":0, # as easy to do. See UI / UI_math / rectangle_surround() + "rects":[] # for details of this implementation. + } if pm_project.is_legacy(project): win.story = story.get_legacy(project) @@ -106,6 +110,7 @@ def run(win): win.current["scroll"] = [0,0] win.current["project"] = "" win.current["tool"] = "selection" + win.current["draw_dot"] = "end" previous(win) @@ -219,6 +224,9 @@ def pmdrawing(pmdrawing, main_layer, win): # 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"] = [] diff --git a/studio/studio_nodes.py b/studio/studio_nodes.py index 206a2ee..e79b7fa 100644 --- a/studio/studio_nodes.py +++ b/studio/studio_nodes.py @@ -36,7 +36,7 @@ def node_dot(layer, win, x, y, direction="in", entry="end"): if entry.startswith("scene:") or entry in ["start", "end"]: - UI_color.set(layer, win, "progress_background") + UI_color.set(layer, win, "node_script") else: UI_color.set(layer, win, "node_imagefile") @@ -47,8 +47,68 @@ def node_dot(layer, win, x, y, direction="in", entry="end"): 0, 6) - - + if int(win.current["mx"]) in range(int(x), int(x+12))\ + and int(win.current["my"]) in range(int(y), int(y+12)): + UI_color.set(layer, win, "text_normal") + UI_elements.roundrect(layer, win, + x, + y, + 0, + 0, + 6, + fill=False) + layer.stroke() + + # Start drawing the line + + if win.current["LMB"] and direction != "in": + + # Out point + + win.current["tool"] = "connect" + win.current["draw_dot"] = raw_entry + + elif win.current["LMB"] and direction == "in" and win.current["tool"] != "connect": + + # Take out of the in point + try: + found = False + win.current["tool"] = "connect" + for arrow in win.story["arrows"]: + if raw_entry == arrow[1]: + win.current["draw_dot"] = arrow[0]#.copy() + found = arrow + break + if found: + win.story["arrows"].remove(found) + else: + win.current["draw_dot"] = "end" + except: + pass + + + + # Connecting the line + + if win.current["tool"] == "connect" and direction == "in" and not win.current["LMB"]: + + # Connecting the scenes together + + if raw_entry[0] != "file" and win.current["draw_dot"][0] != "file": + + new_arrow = [ + win.current["draw_dot"], + raw_entry + ] + + if new_arrow not in win.story["arrows"]: + win.story["arrows"].append(new_arrow) + + + + + UI_math.filter_arrows(win) + if direction != "in": win.out_dots[entry] = [x+6, y+6] @@ -61,7 +121,7 @@ def node_dot(layer, win, x, y, direction="in", entry="end"): fr = fr[0]+":"+fr[1] try: - UI_color.set(layer, win, "progress_background") + UI_color.set(layer, win, "node_script") layer.move_to( win.out_dots[fr][0], win.out_dots[fr][1] @@ -192,6 +252,9 @@ def scene_node(outlayer, win, x, y, width, height, name="Unknown", fraction=0.0) entry = ['scene', name] + width = max(width,20) + height = max(height,20) + if int(x) in range(int(0-width), int(win.current["w"]))\ and int(y) in range(int(0-height), int(win.current["h"])): @@ -206,7 +269,8 @@ def scene_node(outlayer, win, x, y, width, height, name="Unknown", fraction=0.0) if win.current["LMB"] and entry in win.story["selected"]: if int(win.current["LMB"][0]) in range(int(x), int(x+width))\ - and int(win.current["LMB"][1]) in range(int(y), int(y+height)): + and int(win.current["LMB"][1]) in range(int(y), int(y+height))\ + and win.current["tool"] == "selection": win.current["tool"] = "grab" win.story["active"] = entry @@ -247,12 +311,62 @@ def scene_node(outlayer, win, x, y, width, height, name="Unknown", fraction=0.0) if win.story["active"] not in win.story["selected"]: win.story["active"] = entry + + + + if entry in win.story["selected"]: selected = True if selected: + if win.current["tool"] == "selection": + UI_math.rectangle_surround(win, "selection", + win.szone[0], win.szone[1], + [x,y], [width, height] + ) + + # Now let's make the stratching thing do it's stratching. It's the + # circle in the bottom, right corner of the selection. + + if win.current["tool"] == "scale" and win.current["LMB"] and win.previous["LMB"]: + + + # let's get the points of the selection zone. + zx = win.szone[0][0] + zy = win.szone[0][1] + zsx = win.previous["LMB"][0] + zsy = win.previous["LMB"][1] + + if win.current["mx"] > zx and win.current["my"] > zy: + + + # now let's get the motion fraction. + + mvx = (x - zx) / (zsx - zx) + mvy = (y - zy) / (zsy - zy) + + svx = (win.current["mx"]- zx) / (win.previous["mx"]-zx) + svy = (win.current["my"]- zy) / (win.previous["my"]-zy) + + # now let's apply these + + win.story["scenes"][name]["position"][0]\ + += (win.current["mx"] - win.previous["mx"])*mvx + + win.story["scenes"][name]["position"][1]\ + += (win.current["my"] - win.previous["my"])*mvy + + win.story["scenes"][name]["size"][0]\ + = max(win.story["scenes"][name]["size"][0] * svx, 40) + + win.story["scenes"][name]["size"][1]\ + = max(win.story["scenes"][name]["size"][1] * svy, 40) + + + + # Now let's do the simple grab tool. if win.current["tool"] == "grab": try: @@ -273,17 +387,12 @@ def scene_node(outlayer, win, x, y, width, height, name="Unknown", fraction=0.0) - else: + elif win.current["tool"] != "connect": win.current["tool"] = "selection" - # In case there is a parent event in the scene. - - if win.story["scenes"][name]["parent"]: + - parent = win.story["scenes"][name]["parent"] - win.story["events"][parent]["position"] = [x, y] - win.story["events"][parent]["size"] = [0, 0] except: raise() @@ -304,7 +413,20 @@ def scene_node(outlayer, win, x, y, width, height, name="Unknown", fraction=0.0) fill=False) outlayer.stroke() outlayer.set_line_width(2) + + + + # In case there is a parent event in the scene. + + if win.story["scenes"][name]["parent"]: + parent = win.story["scenes"][name]["parent"] + UI_math.rectangle_surround(win, parent, + win.story["events"][parent]["position"], + win.story["events"][parent]["size"], + [x,y], [width, height] + ) + # Clip UI_elements.roundrect(layer, win, 0, @@ -322,7 +444,7 @@ def scene_node(outlayer, win, x, y, width, height, name="Unknown", fraction=0.0) # top banner - UI_color.set(layer, win, "node_blendfile") + UI_color.set(layer, win, "node_script") layer.rectangle(0,0,width, 20) layer.fill() @@ -438,7 +560,8 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty if win.current["LMB"] and entry in win.story["selected"]: if int(win.current["LMB"][0]) in range(int(x), int(x+width))\ - and int(win.current["LMB"][1]) in range(int(y), int(y+height)): + and int(win.current["LMB"][1]) in range(int(y), int(y+height))\ + and win.current["tool"] == "selection": win.current["tool"] = "grab" win.story["active"] = entry @@ -485,6 +608,40 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty if selected: + if win.current["tool"] == "selection": + UI_math.rectangle_surround(win, "selection", + win.szone[0], win.szone[1], + [x,y], [width, height] + ) + + # Now let's make the stratching thing do it's stratching. It's the + # circle in the bottom, right corner of the selection. + + if win.current["tool"] == "scale" and win.current["LMB"] and win.previous["LMB"]: + + + # let's get the points of the selection zone. + zx = win.szone[0][0] + zy = win.szone[0][1] + zsx = win.previous["LMB"][0] + zsy = win.previous["LMB"][1] + + if win.current["mx"] > zx and win.current["my"] > zy: + + + # now let's get the motion fraction. + + mvx = (x - zx) / (zsx - zx) + mvy = (y - zy) / (zsy - zy) + + # now let's apply these + + win.story["links"][num][2][0]\ + += (win.current["mx"] - win.previous["mx"])*mvx + + win.story["links"][num][2][1]\ + += (win.current["my"] - win.previous["my"])*mvy + if win.current["tool"] == "grab": try: @@ -502,7 +659,7 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty x += win.previous["mx"] - win.previous["LMB"][0] y += win.previous["my"] - win.previous["LMB"][1] - else: + elif win.current["tool"] != "connect": win.current["tool"] = "selection" diff --git a/studio/studio_storyLayer.py b/studio/studio_storyLayer.py index 77d2090..cc88207 100644 --- a/studio/studio_storyLayer.py +++ b/studio/studio_storyLayer.py @@ -411,9 +411,6 @@ def layer(win): sx, sy = win.story["events"][event]["position"] - sx = sx + cx - sy = sy + cy - # Scale ssx, ssy = win.story["events"][event]["size"] @@ -442,34 +439,7 @@ def layer(win): #Draw studio_nodes.scene_node(layer, win, sx, sy, ssx, ssy, name=scene, fraction=sf) - # Let's get events arround the scene. If it's inside the event. - if win.story["scenes"][scene]["parent"]: - parent = win.story["scenes"][scene]["parent"] - - - try: - - # Don't touch these. It's a hard rigging thing. - - if win.story["events"][parent]["position"][0] > sx - cx: - win.story["events"][parent]["position"][0] = sx - cx - - if win.story["events"][parent]["position"][1] > sy - cy: - win.story["events"][parent]["position"][1] = sy - cy - - if win.story["events"][parent]["size"][0]\ - + win.story["events"][parent]["position"][0]+cx < ssx + sx: - win.story["events"][parent]["size"][0] = ssx + sx\ - - win.story["events"][parent]["position"][0] - cx - - if win.story["events"][parent]["size"][1]\ - + win.story["events"][parent]["position"][1]+cy < ssy + sy: - win.story["events"][parent]["size"][1] = ssy + sy\ - - win.story["events"][parent]["position"][1] - cy - - except: - pass # LINKS (Images, Stuff) @@ -484,18 +454,12 @@ def layer(win): studio_nodes.link_node(layer, win, lx, ly, name=linkname, num=num, linktype=linktype ) # In case there is a selection bug - if not win.story["selected"]: + if not win.story["selected"] and win.current["tool"] != "connect": win.current["tool"] = "selection" # Selector visualization if win.current["LMB"] and win.current["tool"] == "selection" and win.url == "story_editor": - # Undo selection - if int(win.current["LMB"][0] - win.current["mx"]) in range(-10, 10)\ - and int(win.current["LMB"][1] - win.current["my"])in range(-10, 10)\ - and 65505 not in win.current["keys"]: - win.story["selected"] = [] - # Draw selection box UI_color.set(layer, win, "progress_background") layer.rectangle( @@ -505,6 +469,97 @@ def layer(win): win.current["LMB"][1] - win.current["my"] ) layer.stroke() + + # Now let's draw the cool AF multi selection zone thingy + + # Draw selection box + if len(win.story["selected"]) > 1 and win.current["tool"] == "selection": + UI_color.set(layer, win, "progress_background") + layer.rectangle( + win.szone[0][0]-10, + win.szone[0][1]-10, + win.szone[1][0]+20, + win.szone[1][1]+20 + ) + layer.stroke() + + # Now I want to make a tiny widget that will resize the stuff. + + if win.story["selected"]: + + if win.current["tool"] == "selection": + + draw_circle = True + if len(win.story["selected"]) == 1: + if win.story["selected"][0][0] != "scene": + draw_circle = False + + if draw_circle: + UI_color.set(layer, win, "node_badfile") + UI_elements.roundrect(layer, win, + win.szone[0][0]+win.szone[1][0], + win.szone[0][1]+win.szone[1][1], + 0, + 0, + 10) + UI_color.set(layer, win, "progress_background") + UI_elements.roundrect(layer, win, + win.szone[0][0]+win.szone[1][0], + win.szone[0][1]+win.szone[1][1], + 0, + 0, + 10, + fill=False) + layer.stroke() + + elif win.current["tool"] == "scale": + UI_color.set(layer, win, "node_badfile") + UI_elements.roundrect(layer, win, + win.current["mx"]-10, + win.current["my"]-10, + 0, + 0, + 10) + UI_color.set(layer, win, "progress_background") + UI_elements.roundrect(layer, win, + win.current["mx"]-10, + win.current["my"]-10, + 0, + 0, + 10, + fill=False) + layer.stroke() + + if int(win.current["mx"]) in range(int(win.szone[0][0]+win.szone[1][0]), int(win.szone[0][0]+win.szone[1][0]+20))\ + and int(win.current["my"]) in range(int(win.szone[0][1]+win.szone[1][1]), int(win.szone[0][1]+win.szone[1][1]+20))\ + and win.current["tool"] == "selection": + + UI_color.set(layer, win, "text_normal") + UI_elements.roundrect(layer, win, + win.szone[0][0]+win.szone[1][0], + win.szone[0][1]+win.szone[1][1], + 0, + 0, + 10, + fill=False) + layer.stroke() + + if win.current["LMB"] and not win.previous["LMB"]: + + win.current["tool"] = "scale" + + if win.current["tool"] == "scale" and not win.current["LMB"]: + win.current["tool"] = "selection" + + # Canceling seletion. I move it here so it would not interfire with the + # the rest of the program. + if win.current["LMB"] and win.current["tool"] == "selection" and win.url == "story_editor": + + # Undo selection + if int(win.current["LMB"][0] - win.current["mx"]) in range(-10, 10)\ + and int(win.current["LMB"][1] - win.current["my"])in range(-10, 10)\ + and 65505 not in win.current["keys"]: + win.story["selected"] = [] # Let's put in the start and the end nodes. These are drawn on top of # everything. @@ -514,5 +569,28 @@ def layer(win): win.current["h"] - 80, 100,40) + # Let's draw the line while connecting 2 scenes together. + + if win.current["tool"] == "connect": + + if not win.current["LMB"]: + win.current["tool"] = "selection" + + fr = win.current["draw_dot"] + if type(fr) == list: + fr = fr[0]+":"+fr[1] + + try: + UI_color.set(layer, win, "node_script") + layer.move_to( + win.out_dots[fr][0], + win.out_dots[fr][1] + ) + layer.line_to(win.current["mx"], win.current["my"]) + layer.stroke() + except: + pass + + return surface