Upload files to 'studio'

This commit is contained in:
Jeison Yehuda Amihud (Blender Dumbass) 2020-12-18 03:47:48 +00:00
parent f9963437eb
commit 64a1322ebd
4 changed files with 536 additions and 17 deletions

View file

@ -33,6 +33,7 @@ def get_list(filepath):
"subtasks":[] # List of subtastks. (In the same format as the checklist)
}
data = open(filepath)
data = data.read()
data = data.split("\n")
@ -331,6 +332,8 @@ def draw(outlayer, win, path, back="story_editor"):
if os.path.exists(win.project+"/"+path):
win.checklists[path] = get_list(win.project+"/"+path)
elif os.path.exists(win.project+"/rnd"+path):
win.checklists[path] = get_list(win.project+"/rnd"+path)
else:
win.checklists[path] = get_list(path)

View file

@ -312,6 +312,7 @@ def draw(outlayer, win):
for e in thing[0][4][:-1]:
fullurl = fullurl+e+" > "
if acur in ["chr", "veh", "loc","obj"]:
itemtype = "assets"
elif not acur:
@ -398,7 +399,7 @@ def draw(outlayer, win):
and int(win.current["LMB"][1]) not in range(int(win.current["my"]-2), int(win.current["my"]+2)):
try:
print(entry)
pop = win.analytics["dates"][entry[0]][itemtype]\
[entry[1]].pop(thing[1])
@ -548,6 +549,9 @@ def draw(outlayer, win):
if entry[1]:
goto = "script"
itemtype = "scenes"
# If asset:
if acur in ["chr", "veh", "loc","obj"]:
# ICON
@ -561,15 +565,15 @@ def draw(outlayer, win):
elif not acur:
itemtype = "files"
else:
goto = "script"
itemtype = "scenes"
if goto == "script":
# ICON
UI_elements.image(layer, win,
"settings/themes/"+win.settings["Theme"]+"/icons/scene.png",
25, win.scroll["schedule"] + current_Y+5, 40, 40)
goto = "script"
itemtype = "scenes"
# Here comes the link button
def do():

View file

@ -834,7 +834,6 @@ def layer(win):
if theday in win.analytics["dates"]:
date = win.analytics["dates"][theday]
print(date)
for i in ["files", "assets", "scenes"]:
if i in date:
for item in date[i]:

View file

@ -426,10 +426,11 @@ def layer(win):
# into the scene. Because if it will have 0 characters it will be automatically
# deleted.
if not win.story["scenes"][scene]["shots"]:
win.story["scenes"][scene]["shots"] = [[
if not win.story["scenes"][scene]["shots"]\
or win.story["scenes"][scene]["shots"][-1][0] == "shot_block":
win.story["scenes"][scene]["shots"].append([
"text_block",[["text", ' ']]
]]
])
# This is a list of parts that are inside the selection. I will populate it
@ -1131,6 +1132,7 @@ def layer(win):
pointer[1] = int(point - (tileX+len(word)*12 - int(win.current["mx"]-x))/12 + len(word))
win.cur = "/"+scene
win.textactive = ""
# This is the logic to draw our selection and logic that
# come with the selection.
@ -1251,6 +1253,7 @@ def layer(win):
# point. I have no idea what could go wrong. Maybe I will reddo the whole
# thing. Maybe few times. IDK.
if 65363 in win.current["keys"]: # RIGHT
pointer[0] = pointer[0]+1
@ -1278,6 +1281,13 @@ def layer(win):
pointer[1] = pointer[0]
#win.current["keys"].remove(65364)
# I'm going to implement some basic clipboard. It will need love in future.
# I just need for now something that will "work" so to speak. See where I
# use the clipboard variable later to learn how it all works.
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) # This is a clipboard object
# If there is a key press that contains a string. Like anything on a keyboard
# where you can actually type. Let's do something with it.
@ -1351,7 +1361,24 @@ def layer(win):
pointer[1] = pointer[0]
point = point + 1
if ORD == 22: # Paste ( Ctrl - V )
cliptext = str(clipboard.wait_for_text())
part[-1] = \
part[-1][:MIN]+\
cliptext+\
part[-1][MAX:]
def clean():
pointer[0] = pointer[0] + len(cliptext)
pointer[1] = pointer[0]
point = point + len(cliptext)
if ORD == 3: # Copy ( Ctrl - C )
clipboard.set_text( part[-1][MIN:MAX] , -1) # VERY BASIC
# If ord 13 it means you pressed enter. And it should be a new line.
# but for some reason it's ord 13. Maybe it is a new line. Who knows
@ -1508,7 +1535,7 @@ def layer(win):
# Making stuff happen
elif u < len(selecwords)-1:
if ORD not in [12, 19]:
if ORD not in [12, 19, 3, 22]: # 3 = Crtl - C, 22 = Ctrl - V
part[-1] = ""
if ORD == 19:
@ -1522,7 +1549,7 @@ def layer(win):
MIN = min(len(part[-1])-1, max(0, min(pointer[1], pointer[0])-p))
MAX = max(0, min(len(part[-1])-1, max(pointer[1], pointer[0])-p))
if ORD not in [12, 19]:
if ORD not in [12, 19, 3, 22]:
part[-1] = part[-1][MAX:]
if ORD == 19:
@ -1678,7 +1705,10 @@ def layer(win):
win.scroll["script"] = 0
win.cur = "/"+left
win.url = "script"
del win.text["scene_name"]
try:
del win.text["scene_name"]
except:
pass
UI_elements.roundrect(layer, win,
win.current["w"]/2-45,
@ -1694,7 +1724,10 @@ def layer(win):
win.scroll["script"] = 0
win.cur = "/"+right
win.url = "script"
del win.text["scene_name"]
try:
del win.text["scene_name"]
except:
pass
UI_elements.roundrect(layer, win,
win.current["w"]/2+5,
@ -1711,7 +1744,10 @@ def layer(win):
def do():
win.url = "story_editor"
win.assets = {}
del win.text["scene_name"]
try:
del win.text["scene_name"]
except:
pass
win.story["selected"] = []
win.scroll["script"] = 0
@ -1731,9 +1767,139 @@ def layer(win):
############# CHECKLIST #################
# Here I want to have some checklists. Now... I have 4 types of new check-
# lists prepared for shots and scene. There are 3 types of checklists for
# a shot. So I can't just simply generate one on the fly. Since I don't
# know whether this shot is a simple shot, animated or VFX. And also I
# don't want to generate folders when they are not nessesary. So I want to
# implement a kind of selection thingy when if a checklists does not exist.
# Now let's first of all display our checklists properly.
if os.path.exists(win.project+"/rnd"+win.cur+"/shot.progress"):
checklist.draw(layer, win, win.project+"/rnd"+win.cur+"/shot.progress", back=win.url)
elif os.path.exists(win.project+"/rnd"+win.cur+"/scene.progress") and not shot:
checklist.draw(layer, win, win.project+"/rnd"+win.cur+"/scene.progress", back=win.url)
else:
# Now if we have no checklist what so ever. We want to give user a way
# to choose to generate one.
x = win.current["w"] / 4 * 3 + 10
y = 10
width = win.current["w"] / 4 - 20
height = win.current["h"] - 20
if shot:
# If we are in a shot I want to give different option to choose from
# then if we are just simply in a scene.
shot_options = {
"shot":"add_shot_live_checklist",
"shot_anim":"add_shot_anim_checklist", # First name of new_file then text on screen
"shot_vfx":"add_shot_vfx_checklist"
}
for num, option in enumerate(shot_options):
# We want to draw a button, a rectangle arround it and the text
# tooltip.
def do():
# First let's make sure that the folder exists. Because
# it might not exists. I think doing it automatically
# makes sense.
try:
os.makedirs(win.project+"/rnd"+win.cur)
except:
pass
# Then we copy the file.
oscalls.copy_file(
win,
os.getcwd()+"/new_file/"+option+".progress",
"/rnd"+win.cur+"/",
"shot.progress")
UI_elements.roundrect(layer, win,
x,
y+(50*num),
width,
40,
10,
button=do,
icon="checklist_new")
UI_color.set(layer, win, "progress_background")
UI_elements.roundrect(layer, win,
x,
y+(50*num),
width,
40,
10,
fill=False)
layer.stroke()
UI_color.set(layer, win, "text_normal")
layer.set_font_size(20)
layer.move_to( x+50, y+(50*num)+25)
layer.show_text(talk.text(shot_options[option]))
else:
# Now... If it's not a shot. We can do it in one line.
# It's pretty simple.
def do():
# First let's make sure that the folder exists. Because
# it might not exists. I think doing it automatically
# makes sense.
try:
os.makedirs(win.project+"/rnd"+win.cur)
except:
pass
# Then we copy the file.
oscalls.copy_file(
win,
os.getcwd()+"/new_file/scene.progress",
"/rnd"+win.cur+"/",
"scene.progress")
UI_elements.roundrect(layer, win,
x,
y,
width,
40,
10,
button=do,
icon="checklist_new")
UI_color.set(layer, win, "progress_background")
UI_elements.roundrect(layer, win,
x,
y,
width,
40,
10,
fill=False)
layer.stroke()
UI_color.set(layer, win, "text_normal")
layer.set_font_size(20)
layer.move_to( x+50, y+25)
layer.show_text(talk.text("add_scene_checklist"))
############## LEFT PANEL #####################
@ -2269,8 +2435,355 @@ def layer(win):
# Okay let's put blend file from the shot. So you could actually
# do work on it.
######### VERSION 20.125 I'm tired. I gonna finish it next time.
# But first. I want to add a seach promt. So I could add new ones
# the same way I do it in any other window. By searching. I think
# it's important to keep the workflow similar.
# I think that if we have no blend files at all. It might give you
# to make a new one with the name of the shot. And all the rest will
# be done by searching. Yeah. Makes sense. Wait. I can put the name of
# the shot in the search. Hm... Okay. Let's make the seach icon first.
UI_elements.image(layer, win,
"settings/themes/"+win.settings["Theme"]+"/icons/search.png",
x+10,
y+win.scroll["script_shots"]+current_Y_shots,
40,
40)
# Now beside it will be out text entry.
UI_elements.text(layer, win, "shot_search",
x+50,
y+win.scroll["script_shots"]+current_Y_shots,
width-55,
40)
current_Y_shots = current_Y_shots + 50
# Now let's get the blend file list. It's going to take a few
# stept. First we are going to try getting all the files in the
# folder. Then filter them by .blend in the end. We do not want
# to show you the .blend1 files. We don't want to show you
# anything.
blendfiles = []
try:
for blend in os.listdir(win.project+"/rnd"+win.cur):
if blend.endswith(".blend"):
blendfiles.append(blend)
except:
pass
# Now since we've got our blendfiles list. We can now draw them.
# But I want to preserve the countinuity with the rest of the
# software. So I will need to draw a little Blendfile node each
# time. For which I'm going to create a node. But this time it's
# going to have 2 icons at the bottom.
############## ############## ##############
# 01.blend # # 02.blend # # 03.blend #
############## ############## ##############
# ____ # # ____ # # ____ #
# ( 0 0 ) # # ( 0 0 ) # # ( 0 0 ) #
# ) ( # # ) ( # # ) ( #
# \__/ # # \__/ # # \__/ #
# # # # # #
############## ############## ##############
# 0 # 0 # # 0 # 0 # # 0 # 0 #
############## ############## ##############
# Those 2 icons in the bottom of each will be buttons for render
# and linking. The linking is what you do to put assets inside
# animation files. A new dialog should be developped for this.
# The rendering will resemble rendering of Blender-Organizer with
# render times analytics and stuff. But will be way more extended.
# For example with an ability to open a render task on another
# computer. So groups of people could work together.
tileX = 5
searchis = win.text["shot_search"]["text"].replace("/","_").replace(" ", "_")\
.replace('"',"_").replace("(","_").replace(")","_").replace("'","_")\
.replace("[","_").replace("]","_").replace("{","_").replace("}","_")
for bn, blend in enumerate(blendfiles):
# Each one will be drawn in it's own little layer. Because
# I want the top bar to have a nice rounded corner and also
# the image to be cut.
# Each one here will 128 pixels wide. ( Because this is the
# resolution of blender-thumbnailer.py thumbnails. And I
# want to save horizontal resolution as much as possible
# But before I render a Blend. I want to exclude it if it's
# not in a search.
if searchis and searchis.lower() not in blend.lower():
continue
# Making the layer
nodesurface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 128, 198)
node = cairo.Context(nodesurface)
node.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
UI_elements.roundrect(node, win,
0,
0,
128,
198,
10,
fill=False)
node.clip()
# Background
UI_color.set(node, win, "dark_overdrop")
node.rectangle(0,0,128, 198)
node.fill()
# Blender icon
UI_elements.image(node, win,
win.project+"/rnd"+win.cur+"/"+blend,
0,
20,
128,
128, cell="shot_blends")
# Banner
UI_color.set(node, win, "node_blendfile")
node.rectangle(0,0,128, 20)
node.fill()
# Filename
UI_color.set(node, win, "text_normal")
node.set_font_size(12)
node.move_to(5, 15)
node.show_text(blend)
# Outputting the layer
layer.set_source_surface(nodesurface,
x+tileX,
y+win.scroll["script_shots"]+current_Y_shots)
layer.paint()
# Here we gonna out 3 buttons:
# 1. Launch the Blend-File
# 2. Link into Blend-File
# 3. Render Blend-File
# Launch the Blend file:
def do():
oscalls.file_open(win, win.project+"/rnd"+win.cur+"/"+blend)
UI_elements.roundrect(layer, win,
x+tileX,
y+win.scroll["script_shots"]+current_Y_shots,
128,
148,
10,
button=do,
fill=False)
layer.stroke()
# Link things into Blend-File
def do():
print("Link")
UI_elements.roundrect(layer, win,
x+tileX+20,
y+win.scroll["script_shots"]+current_Y_shots+152,
40,
40,
10,
icon="obj_link",
button=do)
# Render
def do():
print("Render")
UI_elements.roundrect(layer, win,
x+tileX+65,
y+win.scroll["script_shots"]+current_Y_shots+152,
40,
40,
10,
icon="render",
button=do)
tileX = tileX + 150
if tileX > width - 10 and bn != len(blendfiles)-1:
tileX = 5
current_Y_shots = current_Y_shots + 205
# Now before we are finished. We want to able to add new files
# by typing the names in the search.
if not blendfiles and not searchis:
searchis = shotis
if not searchis.endswith(".blend"):
searchis = searchis + ".blend"
if searchis != ".blend" and searchis not in blendfiles:
# There will be 2 buttons. To add a brand new file and to
# copy one from a different shot. In Blender-Oraniger it
# had a copy-paste kind of system for this. But since we
# have a file selector. I'm going to use it instead. Tho
# tell me if a copy-paste for files is a cool idea.
if tileX > width - 10:
tileX = 5
current_Y_shots = current_Y_shots + 205
# ADD NEW BLEND
def do():
# First let's make sure that the folder exists. Because
# it might not exists. I think doing it automatically
# makes sense.
try:
os.makedirs(win.project+"/rnd"+win.cur)
except:
pass
# Then we copy the file.
oscalls.copy_file(
win,
os.getcwd()+"/new_file/rnd.blend",
"/rnd"+win.cur+"/",
searchis)
# And clear the search
win.text["shot_search"]["text"] = ""
win.images = {}
UI_elements.roundrect(layer, win,
x+tileX,
y+win.scroll["script_shots"]+current_Y_shots,
128,
198,
10,
button=do)
# A little surrounding thing.
UI_color.set(layer, win, "progress_background")
UI_elements.roundrect(layer, win,
x+tileX,
y+win.scroll["script_shots"]+current_Y_shots,
128,
198,
10,
fill=False)
layer.stroke()
# Icon
UI_elements.image(layer, win,
"settings/themes/"+win.settings["Theme"]+"/icons/new_file.png",
x+tileX+44,
y+win.scroll["script_shots"]+current_Y_shots + 70,
40, 40)
# preiew
UI_color.set(layer, win, "text_normal")
layer.set_font_size(12)
layer.move_to(x+tileX+64-len(searchis)*4,
y+win.scroll["script_shots"]+current_Y_shots+150)
layer.show_text(searchis)
tileX = tileX + 150
if tileX > width - 10:
tileX = 5
current_Y_shots = current_Y_shots + 205
# And a copy file here too
# COPY BLEND
def do():
# Now the copy function going to be a tiny bit harder
# since we will need to launch a dialog for you to
# select the file. I think you gonna look for files
# from this scene more often. So let's do that.
def after(win, var):
if var:
try:
os.makedirs(win.project+"/rnd"+win.cur)
except:
pass
# Then we copy the file.
oscalls.copy_file(
win,var,
"/rnd"+win.cur+"/",
searchis)
# And clear the search
win.text["shot_search"]["text"] = ""
win.images = {}
studio_dialogs.file_select(win, shotis+"_blends", after, force=True,
IMAGE=False, BLEND=True, VIDEO=False, FILE=False, CHR=False, VEH=False,
LOC=False, OBJ=False, RND=True, FOLDER=False, SEARCH=scene)
UI_elements.roundrect(layer, win,
x+tileX,
y+win.scroll["script_shots"]+current_Y_shots,
128,
198,
10,
button=do)
# A little surrounding thing.
UI_color.set(layer, win, "progress_background")
UI_elements.roundrect(layer, win,
x+tileX,
y+win.scroll["script_shots"]+current_Y_shots,
128,
198,
10,
fill=False)
layer.stroke()
# Icon
UI_elements.image(layer, win,
"settings/themes/"+win.settings["Theme"]+"/icons/copy_file.png",
x+tileX+44,
y+win.scroll["script_shots"]+current_Y_shots + 70,
40, 40)
# preiew
UI_color.set(layer, win, "text_normal")
layer.set_font_size(12)
layer.move_to(x+tileX+64-len(searchis)*4,
y+win.scroll["script_shots"]+current_Y_shots+150)
layer.show_text(searchis)
current_Y_shots = current_Y_shots + 205
else:
@ -2297,9 +2810,9 @@ def layer(win):
# Scroll
UI_elements.scroll_area(layer, win, "script_shots",
x+0,
y+50,
y+0,
width,
height-50,
height,
current_Y_shots,
bar=True,
mmb=True)