12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139 |
- # THIS FILE IS A PART OF VCStudio
- # PYTHON 3
- # This a console project manager.
- import os
- # 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
- from studio import checklist
- from studio import analytics
- from studio import studio_dialogs
- from studio import schedule
- from studio import history
- def layer(win):
-
-
- # 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.
-
- ############################################################################
-
-
- # 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)
-
-
- 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
-
- UI_elements.roundrect(layer, win,
- win.current["w"]/4+150+(40*num),
- 350,
- 40,
- 40,
- 10,
- do,
- cur,
- tip=talk.text(folds[cur]))
-
-
-
-
- # 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)
-
- 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()
-
- # 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)
-
- # 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")
-
-
- # 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:
- 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
- for f in sorted(os.listdir(win.project+"/dev"+win.cur)):
- 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"
-
- for f in sorted(os.listdir(win.project+"/dev"+win.cur+"/"+fl)):
- 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")
-
-
-
- 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()
-
-
- ############## CHECKLIST ################
-
- if os.path.exists(win.project+"/dev/"+win.cur+"/asset.progress"):
- checklist.draw(layer, win, win.project+"/dev/"+win.cur+"/asset.progress", back=win.url)
- 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")
-
- ############## 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.
-
- leftpanellist = ["scene", "schedule", "history"] # Using the names of the icons.
-
- # 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
- win.current["asset_left_panel"] = "scene" # Then list scenes
- 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)
-
- ### HISTORY ###
-
- if win.current["asset_left_panel"] == "history":
- history.draw(layer, win)
-
-
-
-
- ### SCENES ###
-
- # 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")
-
- # 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:
- do()
-
- if win.current["asset_left_panel"] == "scene":
-
- # 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 = []
-
- for num, block in enumerate(shots):
-
- si = 1
- if block[0] == "shot_block":
- si = 2
-
- found = []
-
- for n, stuff in enumerate(block[si]):
-
- # DIRECT LINK
- #print(block, si)
- 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:
- foundinscene.append([block[1],found,num,n])
- else:
- 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])
-
- 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,
- "settings/themes/"+win.settings["Theme"]+"/icons/scene.png",
- 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]:
- 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)
- else:
- UI_color.set(layer, win, "node_background")
- UI_elements.roundrect(layer, win,
- x,
- y+win.scroll["asset_scenes"]+current_Y_scenes,
- width,
- 30,
- 10)
-
- # 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()
-
- 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
- UI_color.set(layer, win, "text_normal")
- layer.set_font_size(20)
- layer.move_to( sp, y+win.scroll["asset_scenes"] + current_Y_scenes+20)
- layer.show_text(start)
-
-
- # NAME AS MENTIONED IN THE SCRIPT
- 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)
-
- 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
- UI_color.set(layer, win, "text_normal")
- 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)
-
-
-
-
-
-
-
-
-
- return surface
|