Blender-Pipeline/studio/studio_assetLayer.py

1236 lines
40 KiB
Python
Raw Normal View History

2020-12-10 23:08:22 +01:00
# THIS FILE IS A PART OF VCStudio
# PYTHON 3
# This a console project manager.
import os
import threading
2020-12-10 23:08:22 +01:00
# GTK module ( Graphical interface
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
from gi.repository import Gdk
import cairo
# Own modules
from settings import settings
from settings import talk
from settings import fileformats
from settings import oscalls
from project_manager import pm_project
#UI modules
from UI import UI_elements
from UI import UI_color
# story
from studio import story
2020-12-11 18:18:23 +01:00
from studio import checklist
2020-12-10 23:08:22 +01:00
from studio import analytics
from studio import studio_dialogs
2020-12-13 04:06:44 +01:00
from studio import schedule
2020-12-14 04:21:25 +01:00
from studio import history
2020-12-10 23:08:22 +01:00
from network import http_client
2020-12-10 23:08:22 +01:00
def layer(win):
2020-12-11 18:18:23 +01:00
2020-12-10 23:08:22 +01:00
# Making the layer
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, win.current['w'],
win.current['h'])
layer = cairo.Context(surface)
#text setting
layer.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
UI_color.set(layer, win, "dark_overdrop")
layer.rectangle(
0,
0,
win.current["w"],
win.current["h"],
)
layer.fill()
UI_color.set(layer, win, "node_background")
UI_elements.roundrect(layer, win,
win.current["w"]/4,
150,
win.current["w"]/2,
win.current["h"]-190,
10)
############################################################################
# This file will be showing stuff about an asset. It's almost like a folder
# / folders of the asset. But with some extendet functionality. Stuff that
# will be on screen will include.
# Progress Bar
# Checklist
# Scenes list in which the asset is mentioned
# History / Schedules
# It's similar to the old Blender Organizer's Asset thing. But a bit more
# modern looking. I would say.
############################################################################
2020-12-11 18:18:23 +01:00
# before we start I want to make a little safe mechanism. Just in case the
# win.cur is not written properly.
# Parsing the cur to get name and type
name = win.cur[win.cur.rfind("/")+1:]
acur = win.cur.replace(name, "").replace("/", "")
if not os.path.exists(win.project+"/dev/"+win.cur) or not win.cur:
def select_character(win, var):
if var:
win.url = "assets"
win.cur = var
else:
win.url = "story_editor"
if not acur:
acur = "chr"
studio_dialogs.asset_select(win, "select_asset_check", select_character, force=True, cur=acur, SEARCH=name)
2020-12-10 23:08:22 +01:00
if not "asset_cur_folder" in win.current:
win.current["asset_cur_folder"] = "blender"
####### MIDDLE PANNEL #######
def do():
oscalls.Open(win.project+"/dev"+win.cur)
UI_elements.roundrect(layer, win,
win.current["w"]/4+20,
350,
40,
40,
10,
do,
"folder")
folds = {
"blender":"blend_files_folder",
"idea":"reference_folder",
"texture":"tex_folder",
"render":"renders_folder"
}
for num, cur in enumerate(folds):
if win.current["asset_cur_folder"] == cur:
UI_color.set(layer, win, "progress_time")
UI_elements.roundrect(layer, win,
win.current["w"]/4+150+(40*num),
350,
40,
40,
10)
def do():
win.current["asset_cur_folder"] = cur
# FUNCTIONS PER THINGS
# # Why?
# if win.current["asset_cur_folder"] == "idea":
# fl = "reference"
# elif win.current["asset_cur_folder"] == "texture":
# fl = "tex"
# elif win.current["asset_cur_folder"] == "render":
# fl = "renders"
# else:
# fl = ""
# # Remote Server Stuff
# if win.analytics["from-remote-server"]:
# def after(win, var):
# UI_elements.reload_images(win)
# studio_dialogs.http_client_dialog(win, "http-client", after, http_client.get_files, "/dev/"+win.cur+"/"+fl)
2020-12-10 23:08:22 +01:00
UI_elements.roundrect(layer, win,
win.current["w"]/4+150+(40*num),
350,
40,
40,
10,
do,
cur,
tip=talk.text(folds[cur]))
# Little Remote Server thing
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"] = win.cur
studio_dialogs.http_client_update_prompt(win, "http-client-prompt", after)
UI_elements.roundrect(layer, win,
win.current["w"]/4+60,
350,
40,
40,
10,
do,
2023-12-19 18:32:02 +01:00
"download",
tip=talk.text("RemoteAssetUpdates"))
2020-12-10 23:08:22 +01:00
if win.current["remote-folder-data"][win.cur]["missing"] or win.current["remote-folder-data"][win.cur]["changed"]:
count = str(len(win.current["remote-folder-data"][win.cur]["missing"])+len(win.current["remote-folder-data"][win.cur]["changed"]))
UI_color.set(layer, win, "progress_active")
UI_elements.roundrect(layer, win,
win.current["w"]/4+60+25,
350,
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"]/4+60+28,370)
layer.show_text(count)
2020-12-10 23:08:22 +01:00
# Preview
# Making the layer
nodesurface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 300, 300)
node = cairo.Context(nodesurface)
node.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
UI_elements.roundrect(node, win,
0,
0,
300,
300,
10,
fill=False)
node.clip()
if os.path.exists(win.project+"/dev"+win.cur+"/renders/Preview.png"):
UI_elements.image(node, win,
win.project+"/dev"+win.cur+"/renders/Preview.png",
0, 0, 300, 300, cell="big_asset_previews")
elif os.path.exists(win.project+"/dev"+win.cur+"/renders/Preview.jpg"):
UI_elements.image(node, win,
win.project+"/dev"+win.cur+"/renders/Preview.jpg",
0, 0, 300, 300, cell="big_asset_previews")
else:
UI_color.set(node, win, "dark_overdrop")
node.rectangle(0,0,300, 300)
node.fill()
UI_elements.image(node, win,
"settings/themes/"+win.settings["Theme"]+"/icons/"+acur+".png",
130, 130, 40, 40)
2020-12-13 04:06:44 +01:00
def do():
def after(win, var):
win.current["asset_file_selected"] = ""
win.images = {}
if var:
for t in fileformats.images:
if var.endswith(t):
oscalls.copy_file(
win,
var,
"/dev"+win.cur+"/renders/",
"Preview.png")
break
studio_dialogs.file_select(win, name+"_preview", after, force=True,
IMAGE=True, BLEND=False, VIDEO=True, FILE=False, CHR=True, VEH=True,
LOC=True, OBJ=True, RND=False, FOLDER=False, SEARCH=win.cur+" renders")
UI_elements.roundrect(node, win,
2,
2,
296,
296,
10,
button=do,
fill=False,
offset=[
win.current["w"]/4+20,
20
]
)
node.stroke()
2020-12-10 23:08:22 +01:00
# Outputting the layer
layer.set_source_surface(nodesurface,
win.current["w"]/4+20,
20)
layer.paint()
# Name of the asset
UI_elements.image(layer, win,
"settings/themes/"+win.settings["Theme"]+"/icons/"+acur+".png",
win.current["w"]/4+360, 210, 40, 40)
UI_color.set(layer, win, "text_normal")
layer.set_font_size(30)
layer.move_to(win.current["w"]/4+410,240)
layer.show_text(name)
# Fraction
fraction = story.get_asset_data(win, win.cur)["fraction"]
UI_color.set(layer, win, "progress_background")
UI_elements.roundrect(layer, win,
win.current["w"]/4+350,
270,
(win.current["w"]/2-370),
0,
10)
UI_color.set(layer, win, "progress_active")
UI_elements.roundrect(layer, win,
win.current["w"]/4+350,
270,
(win.current["w"]/2-370)*fraction,
0,
10)
2020-12-19 11:20:34 +01:00
# Before search. On the other side when you have done the asset there will
# be a little configure icon. This is configuration for linking. Creating
# the /ast/ blend.file and autolink.data file. So the linker could link
# the files into the animation scene.
#
# See:
# studio/studio_shot_linkLayer.py
# studio/bpy_do_linking.py
# studio/studio_asset_configureLayer.py
def do():
def after(win, var):
print(var)
studio_dialogs.asset_configure(win, "configuring_asset", after, win.cur)
UI_elements.roundrect(layer, win,
win.current["w"]/4*3-60,
210,
40,
40,
10,
button=do,
icon="link_configure")
2020-12-10 23:08:22 +01:00
# Search
UI_elements.image(layer, win, "settings/themes/"\
+win.settings["Theme"]+"/icons/search.png",
win.current["w"]-280-win.current["w"]/4,
350,
40,
40)
UI_elements.text(layer, win, "in_asset",
win.current["w"]-240-win.current["w"]/4,
350,
220,
40)
# FILES
# In case the user made the folder manually.
try:
os.mkdir(win.project+"/dev/"+win.cur)
except:
pass
try:
2020-12-10 23:08:22 +01:00
os.mkdir(win.project+"/dev/"+win.cur+"/renders")
os.mkdir(win.project+"/dev/"+win.cur+"/reference")
os.mkdir(win.project+"/dev/"+win.cur+"/tex")
except:
pass
# Now let's prepare the frame
width = win.current["w"]/2- 40
height = win.current["h"] - 500
# Making the layer
nodesurface = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(width), int(height))
node = cairo.Context(nodesurface)
node.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
UI_elements.roundrect(node, win,
0,
0,
width,
height,
10,
fill=False)
node.clip()
# Now let's prepare the scrooler
tileX = 20
current_Y = 10
if "assets" not in win.scroll:
win.scroll["assets"] = 0
###########################
# Let's get the list of the files first.
files = []
newcreate = win.text["in_asset"]["text"].replace("/","_").replace(" ", "_")\
.replace('"',"_").replace("(","_").replace(")","_").replace("'","_")\
.replace("[","_").replace("]","_").replace("{","_").replace("}","_")
foundblend = True
found_in = False
if win.current["asset_cur_folder"] == "blender":
foundblend = False
# Let's see if an asset blend file exists.
if os.path.exists(win.project+"/ast"+win.cur+".blend") and not newcreate:
files.append(["/ast"+win.cur+".blend", "node_asset"])
foundblend = True
2020-12-14 04:21:25 +01:00
for f in sorted(os.listdir(win.project+"/dev"+win.cur)):
2020-12-10 23:08:22 +01:00
if not os.path.isdir(win.project+"/dev"+win.cur+"/"+f):
# This is for only the blend files. So let's filter the out of all
# the noise. For all files there is a folder icon.
if newcreate == f:
found_in = True
if newcreate and newcreate.lower() not in f.lower():
continue
if f.endswith(".blend"):
files.append(["/dev"+win.cur+"/"+f, "node_blendfile"])
foundblend = True
else:
# This all the rest of the files.
if win.current["asset_cur_folder"] == "idea":
fl = "reference"
elif win.current["asset_cur_folder"] == "texture":
fl = "tex"
elif win.current["asset_cur_folder"] == "render":
fl = "renders"
2020-12-14 04:21:25 +01:00
for f in sorted(os.listdir(win.project+"/dev"+win.cur+"/"+fl)):
2020-12-10 23:08:22 +01:00
if not os.path.isdir(win.project+"/dev"+win.cur+"/"+fl+"/"+f):
if newcreate == f:
found_in = True
if newcreate and newcreate.lower() not in f.lower():
continue
# Now it has to be image or video files. For the rest you have
# the folder icon.
for t in fileformats.images:
if f.endswith(t):
files.append(["/dev"+win.cur+"/"+fl+"/"+f, "node_imagefile"])
for t in fileformats.videos:
if f.endswith(t):
files.append(["/dev"+win.cur+"/"+fl+"/"+f, "node_videofile"])
# Let's make sure that we have at least some blendfile there.
if not foundblend and not newcreate:
oscalls.copy_file(
win,
os.getcwd()+"/new_file/"+acur+".blend",
"/dev"+win.cur+"/",
name+".blend")
# This is executed on the first frame when you click onto an asset.
if win.current["in-asset-remote-server"]:
# First we gonna change the active folder to view the Blend files.
# This is important for the function for the remote server.
win.current["asset_cur_folder"] = "blender"
# Let's also check for updates on the file
# Remote Server Stuff
if win.analytics["from-remote-server"]:
# Checking date [ FOLDER NAME ] [ FILES TO CHECK FOR ]
check_folders = {"/dev"+win.cur : "*",
"/ast/"+acur : name+"*",
"/dev"+win.cur+"/renders" : "*",
"/dev"+win.cur+"/reference" : "*",
"/dev"+win.cur+"/tex" : "*",
}
check_updates = threading.Thread(target=http_client.get_folder_info,
args=(win, check_folders, win.cur, ))
check_updates.setDaemon(True)
check_updates.start()
win.current["in-asset-remote-server"] = False
2020-12-10 23:08:22 +01:00
if "asset_file_selected" not in win.current:
win.current["asset_file_selected"] = ""
for filename, thecoloris in files:
if int(current_Y + win.scroll["assets"]) in range(0-200, height):
# Making the layer
node2surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 170, 200)
node2 = cairo.Context(node2surface)
node2.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
UI_elements.roundrect(node2, win,
0,
0,
170,
200,
10,
fill=False)
node2.clip()
# Background
UI_color.set(node2, win, "dark_overdrop")
node2.rectangle(0,0,170, 200)
node2.fill()
# Banner
UI_color.set(node2, win, thecoloris)
node2.rectangle(0,0,170, 20)
node2.fill()
# Outputting the layer
node.set_source_surface(node2surface,
tileX-10,
current_Y + win.scroll["assets"] )
node.paint()
UI_elements.image(node, win, win.project+filename,
tileX,
current_Y + win.scroll["assets"] + 30,
150,
150)
UI_color.set(node, win, "text_normal")
node.set_font_size(12)
node.move_to(tileX,
current_Y + win.scroll["assets"]+15)
node.show_text(filename[filename.rfind("/")+1:][:22])
# If selected
node.set_line_width(4)
if win.current["asset_file_selected"] == win.project+filename:
UI_color.set(node, win, "progress_background")
UI_elements.roundrect(node, win,
tileX-10,
current_Y + win.scroll["assets"],
170,
200,
10,
fill=False)
node.stroke()
# Button to activate it
def do():
if win.current["asset_file_selected"] != win.project+filename:
win.current["asset_file_selected"] = win.project+filename
else:
oscalls.file_open(win, win.project+filename)
UI_elements.roundrect(node, win,
tileX-10,
current_Y + win.scroll["assets"],
170,
200,
10,
button=do,
tip=filename,
fill=False,
clip=[
win.current["w"]/4+20,
400,
width,
height,
],
offset=[
win.current["w"]/4+20,
400])
node.stroke()
node.set_line_width(2)
tileX += 200
if tileX > width-180:
tileX = 20
current_Y += 230
###########################
# Now i'd like to make things addable. For now if it's a blends selected
# there will an option to add new one and an option to copy. While other
# files will have an option of only copy. (At least for now. Untill I
# figure out what new images will it give.)
if not found_in and newcreate:
if win.current["asset_cur_folder"] == "blender"\
and not newcreate.endswith(".blend"):
newcreate = newcreate+".blend"
def do():
def after(win, var):
newcreate = win.text["in_asset"]["text"].replace("/","_").replace(" ", "_")\
.replace('"',"_").replace("(","_").replace(")","_").replace("'","_")\
.replace("[","_").replace("]","_").replace("{","_").replace("}","_")
win.text["in_asset"]["text"] = ""
win.current["asset_file_selected"] = ""
win.images = {}
if var:
if win.current["asset_cur_folder"] == "blender"\
and var.endswith(".blend"):
if not newcreate.endswith(".blend"):
newcreate = newcreate+".blend"
oscalls.copy_file(
win,
var,
"/dev"+win.cur+"/",
newcreate)
else:
# In case the copying file is not a blend file. Let's
# make sure that it's infect an image.
for t in fileformats.images:
if var.endswith(t):
if not newcreate.endswith(t):
newcreate = newcreate + "." + t
if win.current["asset_cur_folder"] == "idea":
fl = "reference"
elif win.current["asset_cur_folder"] == "texture":
fl = "tex"
elif win.current["asset_cur_folder"] == "render":
fl = "renders"
oscalls.copy_file(
win,
var,
"/dev"+win.cur+"/"+fl+"/",
newcreate)
break
if win.current["asset_cur_folder"] == "blender":
studio_dialogs.file_select(win, name+"_blends", after, force=True,
IMAGE=False, BLEND=True, VIDEO=False, FILE=False, CHR=True, VEH=True,
LOC=True, OBJ=True, RND=False, FOLDER=False)
elif win.current["asset_cur_folder"] == "idea":
studio_dialogs.file_select(win, name+"_reference", after, force=True,
IMAGE=True, BLEND=False, VIDEO=True, FILE=False, CHR=True, VEH=True,
LOC=True, OBJ=True, RND=False, FOLDER=False, SEARCH="reference")
elif win.current["asset_cur_folder"] == "texture":
studio_dialogs.file_select(win, name+"_reference", after, force=True,
IMAGE=True, BLEND=False, VIDEO=True, FILE=False, CHR=True, VEH=True,
LOC=True, OBJ=True, RND=False, FOLDER=False, SEARCH="tex")
elif win.current["asset_cur_folder"] == "render":
studio_dialogs.file_select(win, name+"_reference", after, force=True,
IMAGE=True, BLEND=False, VIDEO=True, FILE=False, CHR=True, VEH=True,
LOC=True, OBJ=True, RND=False, FOLDER=False, SEARCH="renders")
UI_elements.roundrect(node, win,
tileX-10,
current_Y + win.scroll["assets"],
170,
200,
10,
button=do,
tip=talk.text("copy_file_as")+" "+newcreate,
clip=[
win.current["w"]/4+20,
400,
width,
height,
],
offset=[
win.current["w"]/4+20,
400])
UI_color.set(node, win, "progress_background")
UI_elements.roundrect(node, win,
tileX-10,
current_Y + win.scroll["assets"],
170,
200,
10,
fill=False)
node.stroke()
UI_elements.image(node, win,
"settings/themes/"+win.settings["Theme"]+"/icons/copy_file.png",
tileX+55,
current_Y + win.scroll["assets"] + 70,
40, 40)
UI_color.set(node, win, "text_normal")
node.set_font_size(12)
node.move_to(tileX+75-len(newcreate)*4,
current_Y + win.scroll["assets"]+150)
node.show_text(newcreate)
tileX += 200
if tileX > width-180:
tileX = 20
current_Y += 230
if not found_in and newcreate and win.current["asset_cur_folder"] == "blender":
if not newcreate.endswith(".blend"):
newcreate = newcreate+".blend"
def do():
oscalls.copy_file(
win,
os.getcwd()+"/new_file/"+acur+".blend",
"/dev"+win.cur+"/",
newcreate)
win.text["in_asset"]["text"] = ""
win.current["asset_file_selected"] = ""
win.images = {}
UI_elements.roundrect(node, win,
tileX-10,
current_Y + win.scroll["assets"],
170,
200,
10,
button=do,
tip=talk.text("create_new_blend_file")+" "+newcreate,
clip=[
win.current["w"]/4+20,
400,
width,
height,
],
offset=[
win.current["w"]/4+20,
400])
UI_color.set(node, win, "progress_background")
UI_elements.roundrect(node, win,
tileX-10,
current_Y + win.scroll["assets"],
170,
200,
10,
fill=False)
node.stroke()
UI_elements.image(node, win,
"settings/themes/"+win.settings["Theme"]+"/icons/new_file.png",
tileX+55,
current_Y + win.scroll["assets"] + 70,
40, 40)
UI_color.set(node, win, "text_normal")
node.set_font_size(12)
node.move_to(tileX+75-len(newcreate)*4,
current_Y + win.scroll["assets"]+150)
node.show_text(newcreate)
current_Y += 230
UI_elements.scroll_area(layer, win, "assets",
win.current["w"]/4+20,
400,
width,
height,
current_Y,
bar=True,
mmb=True,
url="assets")
# Outputting the layer
layer.set_source_surface(nodesurface,
win.current["w"]/4+20,
400)
layer.paint()
2020-12-11 18:18:23 +01:00
############## CHECKLIST ################
if os.path.exists(win.project+"/dev/"+win.cur+"/asset.progress"):
2020-12-13 04:06:44 +01:00
checklist.draw(layer, win, win.project+"/dev/"+win.cur+"/asset.progress", back=win.url)
2020-12-11 18:18:23 +01:00
else:
# If asset.progress does not exist in the folder it will try to create.
# one. The only problem with now is language support. I have some ideas
# I will need to work on it. But later.
oscalls.copy_file(
win,
os.getcwd()+"/new_file/"+acur+".progress",
"/dev"+win.cur+"/",
"asset.progress")
2020-12-13 04:06:44 +01:00
############## LEFT PANEL ################
# Here on the left panel I want to have 3 things. Which is already more then
# the legacy organizer. But who are we deceiving? This is way cooler then
# the legacy organizer.
2020-12-15 21:38:04 +01:00
leftpanellist = ["scene", "schedule", "history"] # Using the names of the icons.
2020-12-13 04:06:44 +01:00
# We need to choose the correct category based smartly on the project's
# current progress. Or at least on the current progress of this asset.
if "asset_left_panel" not in win.current:
if fraction == 1.0: # If the asset is done
2020-12-15 21:38:04 +01:00
win.current["asset_left_panel"] = "scene" # Then list scenes
2020-12-13 04:06:44 +01:00
else: # Other
win.current["asset_left_panel"] = "schedule" # List schedules
# A little banner.
UI_color.set(layer, win, "node_background")
UI_elements.roundrect(layer, win,
10,
10,
win.current["w"]/4-20,
50,
10)
for num, thing in enumerate(leftpanellist):
if win.current["asset_left_panel"] == thing:
UI_color.set(layer, win, "progress_time")
UI_elements.roundrect(layer, win,
20+(40*num),
15,
40,
40,
10)
def do():
win.current["asset_left_panel"] = thing
UI_elements.roundrect(layer, win,
20+(40*num),
15,
40,
40,
10,
do,
thing)
### SCHEDULES ###
if win.current["asset_left_panel"] == "schedule":
schedule.draw(layer, win)
2020-12-14 04:21:25 +01:00
### HISTORY ###
if win.current["asset_left_panel"] == "history":
history.draw(layer, win)
2020-12-14 04:21:25 +01:00
### SCENES ###
2020-12-13 04:06:44 +01:00
2020-12-25 15:20:34 +01:00
# Documentation entry
def do():
def after(win, var):
pass
studio_dialogs.help(win, "help", after, SEARCH=talk.text("documentation_assets"))
UI_elements.roundrect(layer, win,
win.current["w"]-40-win.current["w"]/4-50,
win.current["h"]-80,
40,
40,
10,
do,
"question")
2020-12-10 23:08:22 +01:00
# CANCEl
def do():
win.url = "story_editor"
win.assets = {}
win.current["asset_file_selected"] = ""
UI_elements.roundrect(layer, win,
win.current["w"]-40-win.current["w"]/4,
win.current["h"]-80,
40,
40,
10,
button=do,
icon="cancel",
tip=talk.text("cancel"))
# Short cut ESC
if 65307 in win.current["keys"] and not win.textactive:
2020-12-14 04:21:25 +01:00
do()
2020-12-15 21:38:04 +01:00
if win.current["asset_left_panel"] == "scene":
2020-12-14 04:21:25 +01:00
# Here I want to parse the story data in pusuit of all the scenes that
# have the asset. I think I'm going to make it per shot based. Like
# you have the scenes. And you can open them to enter shots. Maybe with
# a tiny exserp from the story.
if "asset_scenes" not in win.scroll:
win.scroll["asset_scenes"] = 0
if "asset_scene_selected" not in win.current:
win.current["asset_scene_selected"] = False
x = 10
y = 70
width = win.current["w"] / 4 - 20
height = win.current["h"] - 80
UI_elements.roundrect(layer, win,
x,
y,
width,
height,
10,
fill=False)
layer.clip()
current_Y_scenes = 0
scenes = win.story["scenes"]
for scene in scenes:
fraction = scenes[scene]["fraction"]
shots = scenes[scene]["shots"]
foundinscene = []
2020-12-15 21:38:04 +01:00
for num, block in enumerate(shots):
2020-12-14 04:21:25 +01:00
si = 1
2020-12-15 21:38:04 +01:00
if block[0] == "shot_block":
2020-12-14 04:21:25 +01:00
si = 2
found = []
for n, stuff in enumerate(block[si]):
2020-12-15 21:38:04 +01:00
# DIRECT LINK
#print(block, si)
2020-12-14 04:21:25 +01:00
if stuff[0] == "link" and stuff[1] == win.cur:
start = ""
part = stuff[-1]
end = ""
if n > 0:
start = block[si][n-1][-1]
start = start.replace("\n", " ")
if n < len(block[si])-1:
end = block[si][n+1][-1]
end = end.replace("\n", " ")
found = [start, part, end]
if si == 2:
2020-12-15 21:38:04 +01:00
foundinscene.append([block[1],found,num,n])
2020-12-14 04:21:25 +01:00
else:
2020-12-15 21:38:04 +01:00
foundinscene.append(["",found,num,n])
# FRASE LINK
if stuff[0] == "frase" and stuff[1][0] == "link" and stuff[1][1] == win.cur:
start = ""
part = stuff[1][-1]
end = ""
if n < len(block[si])-1:
end = " : "+stuff[-1]
found = [start, part, end]
if si == 2:
foundinscene.append([block[1],found,num ,n])
else:
foundinscene.append(["",found,num ,n])
2020-12-14 04:21:25 +01:00
if foundinscene:
UI_color.set(layer, win, "node_background")
UI_elements.roundrect(layer, win,
x,
y+win.scroll["asset_scenes"]+current_Y_scenes,
width,
70,
10)
# ICON
UI_elements.image(layer, win,
2020-12-15 21:38:04 +01:00
"settings/themes/"+win.settings["Theme"]+"/icons/scene.png",
2020-12-14 04:21:25 +01:00
20, y+win.scroll["asset_scenes"] + current_Y_scenes+5, 40, 40)
# SELECTION
def do():
if win.current["asset_scene_selected"] == scene:
win.current["asset_scene_selected"] = False
else:
win.current["asset_scene_selected"] = scene
UI_elements.roundrect(layer, win,
x,
y+win.scroll["asset_scenes"]+current_Y_scenes,
width,
70,
10,
button=do,
fill=False)
layer.stroke()
# SCENE NAME
UI_color.set(layer, win, "text_normal")
layer.set_font_size(20)
layer.move_to( x+60, y+win.scroll["asset_scenes"] + current_Y_scenes+30)
layer.show_text(scene)
# FRACTION
UI_color.set(layer, win, "progress_background")
UI_elements.roundrect(layer, win,
x+10,
y+50+win.scroll["asset_scenes"] + current_Y_scenes,
width-20,
0,
5)
UI_color.set(layer, win, "progress_active")
UI_elements.roundrect(layer, win,
x+10,
y+50+win.scroll["asset_scenes"] + current_Y_scenes,
(width-20)*fraction,
0,
5)
# IF SELECTED
if win.current["asset_scene_selected"] == scene:
UI_color.set(layer, win, "progress_background")
UI_elements.roundrect(layer, win,
x,
y+win.scroll["asset_scenes"]+current_Y_scenes,
width,
70,
10,
fill=False)
layer.stroke()
# Here if the current scene is selected I want to draw all
# the parts of the scene. It's already a bit more complex
# then what was in the Blender-Organizer legacy.
current_Y_scenes = current_Y_scenes + 80
for block in foundinscene:
# If it's a shot let's mark in the different color.
if block[0]:
2020-12-17 07:34:19 +01:00
if "shot_colors" not in win.story:
win.story["shot_colors"] = {}
surl = "/"+scene+"/"+block[0]
if surl not in win.story["shot_colors"]:
rcolors = [
"shot_1",
"shot_2",
"shot_3",
"shot_4",
"shot_5"
]
win.story["shot_colors"][surl] = rcolors[len(win.story["shot_colors"]) % len(rcolors)]
col = win.story["shot_colors"][surl]
UI_color.set(layer, win, col)
2020-12-14 04:21:25 +01:00
else:
2020-12-17 07:34:19 +01:00
UI_color.set(layer, win, "node_background")
2020-12-14 04:21:25 +01:00
UI_elements.roundrect(layer, win,
x,
y+win.scroll["asset_scenes"]+current_Y_scenes,
width,
30,
10)
2020-12-15 21:38:04 +01:00
# GET TO THE SCENE BUTTON
def do():
win.current["script_find"] = [block[2],block[3]]
win.url = "script"
print(scene)
win.cur = "/"+scene+"/"+block[0]
print(win.cur)
UI_elements.roundrect(layer, win,
x,
y+win.scroll["asset_scenes"]+current_Y_scenes,
width,
30,
10,
button=do,
fill=False)
layer.stroke()
2020-12-14 04:21:25 +01:00
start = block[1][0]
name = block[1][1]
end = block[1][2]
sp = x+width/2-len(name)*12/2-len(start)*12
np = x+width/2-len(name)*12/2
ep = x+width/2+len(name)*12/2
if sp > x+5 and x+5 + ep + len(end)*12 > width:
sp = x+5
np = x+5 + len(start)*12
ep = x+5 + len(start)*12 + len(name)*12
elif ep + len(end)*12 < width and sp < x+5:
ep = width - len(end)*12
np = ep - len(name)*12
sp = np - len(start)*12
# BEFORE NAME
2020-12-15 21:38:04 +01:00
UI_color.set(layer, win, "text_normal")
2020-12-14 04:21:25 +01:00
layer.set_font_size(20)
layer.move_to( sp, y+win.scroll["asset_scenes"] + current_Y_scenes+20)
layer.show_text(start)
2020-12-15 21:38:04 +01:00
2020-12-14 04:21:25 +01:00
# NAME AS MENTIONED IN THE SCRIPT
2020-12-15 21:38:04 +01:00
UI_color.set(layer, win, "node_asset")
UI_elements.roundrect(layer, win,
np-6,
y+win.scroll["asset_scenes"]+current_Y_scenes+2,
len(name)*12+12,
26,
10)
2020-12-14 04:21:25 +01:00
UI_color.set(layer, win, "text_normal")
layer.set_font_size(20)
layer.move_to(np, y+win.scroll["asset_scenes"] + current_Y_scenes+20)
layer.show_text(name)
# AFTER NAME
2020-12-15 21:38:04 +01:00
UI_color.set(layer, win, "text_normal")
2020-12-14 04:21:25 +01:00
layer.set_font_size(20)
layer.move_to( ep, y+win.scroll["asset_scenes"] + current_Y_scenes+20)
layer.show_text(end)
current_Y_scenes = current_Y_scenes + 40
else:
current_Y_scenes = current_Y_scenes + 80
# Scroll
UI_elements.scroll_area(layer, win, "asset_scenes",
x+0,
y+50,
width,
height-50,
current_Y_scenes,
bar=True,
mmb=True)
2020-12-10 23:08:22 +01:00
return surface