Upload files to 'studio'

This commit is contained in:
Jeison Yehuda Amihud (Blender Dumbass) 2020-12-09 02:29:21 +00:00
parent ddf32fefbf
commit 8d20ed3ca7
8 changed files with 881 additions and 71 deletions

View file

@ -600,12 +600,15 @@ def get_asset_data(win, name, force=False):
"fraction":0.0
}
try:
# Now let's get a fraction of the asset
if os.path.exists(win.project+"/ast/"+name+".blend"):
data["fraction"] = 1.0
else:
check = checklist.get_list(win.project+"/dev/"+name+"/asset.progress")
data["fraction"] = check["fraction"]
except:
pass
win.assets[name] = data

View file

@ -0,0 +1,306 @@
# 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 project_manager import pm_project
#UI modules
from UI import UI_elements
from UI import UI_color
# story
from studio import story
def layer(win, call):
# 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,
40,
40,
win.current["w"]-80,
win.current["h"]-80,
10)
############################################################################
# Before we start anything. I would like to refresh the cash of the assets.
# so I would have the most up to date list / fractions of each item.
# In the studio/story.py there is the get_asset_data() functions. Which if
# you look closly just loads fraction into a dictionary called win.assets
# from which we can read directly.
# The function is designed to give load the fraction ones and then just give
# you one from the RAM. So it's not always going to read the asset.progress
# files which is not too good. Since I want to have a good idea about the
# asset's actuall fraction.
# One way I can force it to update is by using the force argument. But doing
# it on every frame defeats the purpose of the function entirelly. So here
# what I'm going to do. Each time I close this window. AKA return anything
# I am also going to wipe the dictionary win.asset clean. It will take one
# frame of potential lag to load everything back ( at least the stuff that's
# ont the screen in a given moment.
# Also to make sure that this dialog has the up to date info. I will do it
# as well in the studio_dialogs.py when initilizing this function. So yeah.
# Let's continue with the program.
############################################################################
####### TOP PANEL #######
for num, cur in enumerate(["chr","veh","loc","obj"]):
if win.current["asset_cur"] == cur:
UI_color.set(layer, win, "progress_time")
UI_elements.roundrect(layer, win,
50+(40*num),
50,
40,
40,
10)
def do():
win.current["asset_cur"] = cur
UI_elements.roundrect(layer, win,
50+(40*num),
50,
40,
40,
10,
do,
cur,
tip=talk.text(cur))
# In case the user is confused
UI_color.set(layer, win, "text_normal")
layer.set_font_size(30)
layer.move_to(250,80)
layer.show_text(talk.text(win.current["asset_cur"]))
# Search
UI_elements.image(layer, win, "settings/themes/"\
+win.settings["Theme"]+"/icons/search.png",
win.current["w"]-440,
50,
40,
40)
UI_elements.text(layer, win, "asset_select_search",
win.current["w"]-400,
50,
350,
40)
# CANCEl
def do():
win.current["calls"][call]["var"] = False
win.assets = {}
UI_elements.roundrect(layer, win,
win.current["w"]-80,
win.current["h"]-80,
40,
40,
10,
button=do,
icon="cancel",
tip=talk.text("cancel"))
# Now let's prepare the ground for the next part.
UI_elements.roundrect(layer, win,
50,
100,
win.current["w"]-100,
win.current["h"]-200,
10,
fill=False)
layer.clip()
UI_color.set(layer, win, "dark_overdrop")
layer.rectangle(
0,
0,
win.current["w"],
win.current["h"],
)
layer.fill()
tileX = 70
current_Y = 0
if "asset_select" not in win.scroll:
win.scroll["asset_select"] = 0
###########################
for asset in os.listdir(win.project+"/dev/"+win.current["asset_cur"]):
if os.path.isdir(win.project+"/dev/"+win.current["asset_cur"]+"/"+asset):
okay = True
# Search
if win.text["asset_select_search"]["text"]\
and win.text["asset_select_search"]["text"].lower() not in asset.lower():
okay = False
if okay:
if int(current_Y + win.scroll["asset_select"] + 100) in range(0-100, win.current["h"]):
UI_color.set(layer, win, "node_asset")
UI_elements.roundrect(layer, win,
tileX-10,
current_Y + win.scroll["asset_select"] + 120,
170,
200,
10)
# Previes image
if os.path.exists(win.project+"/dev/"+win.current["asset_cur"]+"/"+asset+"/renders/Preview.png"):
UI_elements.image(layer, win, win.project+"/dev/"+win.current["asset_cur"]+"/"+asset+"/renders/Preview.png",
tileX,
current_Y + win.scroll["asset_select"] + 140,
150,
150)
elif os.path.exists(win.project+"/dev/"+win.current["asset_cur"]+"/"+asset+"/renders/Preview.jpg"):
UI_elements.image(layer, win, win.project+"/dev/"+win.current["asset_cur"]+"/"+asset+"/renders/Preview.jpg",
tileX,
current_Y + win.scroll["asset_select"] + 140,
150,
150)
else:
UI_elements.image(layer, win, "settings/themes/"+win.settings["Theme"]+"/icons/"+win.current["asset_cur"]+".png",
tileX+55,
current_Y + win.scroll["asset_select"] + 150+55,
150,
150)
# Progress bar
fraction = story.get_asset_data(win, win.current["asset_cur"]+"/"+asset)["fraction"]
UI_color.set(layer, win, "progress_background")
UI_elements.roundrect(layer, win,
tileX,
current_Y + win.scroll["asset_select"] + 300,
150,
0,
5)
UI_color.set(layer, win, "progress_active")
UI_elements.roundrect(layer, win,
tileX,
current_Y + win.scroll["asset_select"] + 300,
150*fraction,
0,
5)
UI_color.set(layer, win, "text_normal")
layer.set_font_size(12)
layer.move_to(tileX,
current_Y + win.scroll["asset_select"] + 135)
layer.show_text(asset[asset.rfind("/")+1:][:22])
# Button to activate it
def do():
win.current["calls"][call]["var"] = "/"+win.current["asset_cur"]+"/"+asset
win.assets = {}
layer.set_line_width(4)
UI_elements.roundrect(layer, win,
tileX-10,
current_Y + win.scroll["asset_select"] + 120,
170,
200,
10,
button=do,
tip=talk.text(win.current["asset_cur"])+": "+asset,
fill=False,
clip=[
50,
100,
win.current["w"]-100,
win.current["h"]-200
])
layer.stroke()
layer.set_line_width(2)
tileX += 200
if tileX > win.current["w"]-220:
tileX = 70
current_Y += 230
###########################
current_Y += 230
UI_elements.scroll_area(layer, win, "asset_select",
50,
100,
win.current["w"]-100,
win.current["h"]-200,
current_Y,
bar=True,
mmb=True,
url="asset_select",
strenght=130
)
return surface

View file

@ -71,10 +71,13 @@ from UI import UI_color
#################
from studio import studio_file_selectLayer
from studio import studio_asset_selectLayer
#################
def file_select(win, name, call):
def file_select(win, name, call, force=False, IMAGE=True, BLEND=False, VIDEO=True,
FILE=False, CHR=True, VEH=True, LOC=True, OBJ=True, RND=False, FOLDER=False,
SEARCH=""):
# This function will select files for any kind of stuff. It will search
# through the files of the project. Similar to image searcher in the old
@ -88,5 +91,84 @@ def file_select(win, name, call):
"draw":studio_file_selectLayer.layer
}
# Here everything is set. I hope so.
# Now let's make a container to save those setting between frames
if force or "file_selector" not in win.current:
win.current["file_selector"] = {
"image" :IMAGE,
"blender":BLEND,
"video" :VIDEO,
"file" :FILE,
"chr" :CHR,
"veh" :VEH,
"loc" :LOC,
"obj" :OBJ,
"vse" :RND,
"folder" :FOLDER
}
# Search text
win.text["file_select_search"] = {
"text" :SEARCH, # Actuall text you are editing.
"cursor":[len(str(SEARCH)),len(str(SEARCH))], # Cursor
"insert":False, # Whether the insert mode is on
"scroll":"file_select_search_scroll" # If multiline. The pointer for the scroll value.
}
# Let's activate the text so you could type immediatly
win.textactive = "file_select_search"
# Let's clear the LMB just in case
win.previous["LMB"] = False
def asset_select(win, name, call, force=False, cur="chr", SEARCH=""):
# This function will be an asset selector. The idea it to be something
# in between itemselector and assets in the same time.
# If you remember
# in the Blender-Organizer there were tabs on the top bar. If you click
# on Characters let's say, you would get a full screen selector to enter
# a given character.
# But for linking and such you would get a small window with only names.
# But with a search dialog.
# Well this dialog will be some kind a merge of both of them. Having both
# a very good cell-based preview type list and search. And could be used
# not only to enter the asset, but also for linking and such.
if name not in win.current["calls"]:
win.current["calls"][name] = {
"var" :None, # This is the variable that we are waiting for
"call":call, # This is what it's going to run when it's done
"url" :"asset_select",
"back":win.url,# This is where it's going to come back when it's done
"draw":studio_asset_selectLayer.layer
}
# Now let's make a container to save those setting between frames
if force or "asset_cur" not in win.current:
win.current["asset_cur"] = cur
# Search text
win.text["asset_select_search"] = {
"text" :SEARCH, # Actuall text you are editing.
"cursor":[len(str(SEARCH)),len(str(SEARCH))], # Cursor
"insert":False, # Whether the insert mode is on
"scroll":"asset_select_search_scroll" # If multiline. The pointer for the scroll value.
}
# Let's activate the text so you could type immediatly
win.textactive = "asset_select_search"
# Wiping the history of the assets. See studio/studio_asset_selectLayer.py
win.assets = {}
# Let's clear the LMB just in case
win.previous["LMB"] = False

View file

@ -88,13 +88,10 @@ def layer(win, call):
# Now that we have the files. There should be some way to filter them.
# I guess let's add a searchbox and buttons on the side for filtering.
# But first let's make a container to save those setting between frames
if "file_selector" not in win.current:
win.current["file_selector"] = {
"image" :True,
"blender":True,
"blender":False,
"video" :True,
"file" :False,
"chr" :True,
@ -105,6 +102,7 @@ def layer(win, call):
"folder" :False
}
############### TOP PANEL ###################
# Left Icons
@ -150,8 +148,7 @@ def layer(win, call):
win.current["w"]-400,
50,
350,
40,
set_text="")
40)
##### BOTTOM BUTTONS ####
@ -278,6 +275,8 @@ def layer(win, call):
if filename.endswith(".blend"):
typefound = True
UI_color.set(layer, win, "node_blendfile")
if "ast/" in filename:
UI_color.set(layer, win, "node_asset")
if not win.current["file_selector"]["blender"]:
okay = False
@ -293,6 +292,10 @@ def layer(win, call):
if okay:
if int(current_Y + win.scroll["file_select"] + 100) in range(0-100, win.current["h"]):
UI_elements.roundrect(layer, win,
tileX-10,
current_Y + win.scroll["file_select"] + 120,
@ -300,8 +303,6 @@ def layer(win, call):
200,
10)
if int(current_Y + win.scroll["file_select"] + 100) in range(0, win.current["h"]):
UI_elements.image(layer, win, win.project+filename,
tileX,
current_Y + win.scroll["file_select"] + 150,
@ -319,6 +320,7 @@ def layer(win, call):
def do():
win.current["calls"][call]["var"] = filename
layer.set_line_width(4)
UI_elements.roundrect(layer, win,
tileX-10,
current_Y + win.scroll["file_select"] + 120,
@ -336,7 +338,7 @@ def layer(win, call):
])
layer.stroke()
layer.set_line_width(2)
tileX += 200
@ -356,7 +358,8 @@ def layer(win, call):
current_Y,
bar=True,
mmb=True,
url="file_select"
url="file_select",
strenght=130
)

View file

@ -10,6 +10,7 @@ gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import cairo
# Own modules
from settings import settings
from settings import talk
@ -70,7 +71,7 @@ def run(win):
win.previous = {}
win.current = {}
win.images = {}
win.imageload = False
win.imageload = 0
win.text = {}
win.textactive = ""
win.scroll = {}
@ -252,9 +253,7 @@ def pmdrawing(pmdrawing, main_layer, win):
else:
win.current["calls"][call]["call"](win, win.current["calls"][call]["var"])
win.url = win.current["calls"][call]["back"]
print()
print(win.current["calls"][call]["back"])
print(win.url)
win.textactive = ""
remlater.append(call)
for call in remlater:
@ -285,6 +284,7 @@ def pmdrawing(pmdrawing, main_layer, win):
win.story["selected"] = []
win.current["tool"] = "selection"
win.current["keys"] = []
win.textactive = ""
# 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.

View file

@ -13,9 +13,12 @@ import cairo
# Own modules
from settings import settings
from settings import talk
from settings import fileformats
from settings import oscalls
# Studio
from studio import story
from studio import studio_dialogs
# UI modules
from UI import UI_testing
@ -163,7 +166,7 @@ def node_dot(layer, win, x, y, direction="in", entry="end"):
fr = "blend:"+link
if entry[entry.find(":")+1:] in link:
if entry[entry.find(":")+1:]+"/" in link or entry[entry.find(":")+1:]+"." in link:
try:
UI_color.set(layer, win, "node_blendfile")
layer.move_to(
@ -289,7 +292,9 @@ def scene_node(outlayer, win, x, y, width, height, name="Unknown", fraction=0.0)
selected = False
if win.url == "story_editor":
if win.url == "story_editor"\
and int(win.current["mx"]) in range(50, int(win.current["w"]-50)) \
and int(win.current["my"]) in range(50, int(win.current["h"]-30)):
if win.current["LMB"] and entry in win.story["selected"]:
if int(win.current["LMB"][0]) in range(int(x), int(x+width))\
@ -569,12 +574,25 @@ def event_node(outlayer, win, x, y, width, height, name="Unknown"):
def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linktype="file"):
filetype = ""
# This node will output links to files.
if linktype == "asset":
width += 50
height += 80
else:
# Let's find out what type of file is it.
for f in fileformats.images:
if name.endswith(f):
filetype = "image"
if not filetype:
for f in fileformats.videos:
if name.endswith(f):
filetype = "video"
if int(x) in range(int(0-width), int(win.current["w"]))\
and int(y) in range(int(0-height), int(win.current["h"])):
@ -590,7 +608,9 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty
selected = False
if win.url == "story_editor":
if win.url == "story_editor"\
and int(win.current["mx"]) in range(50, int(win.current["w"]-50)) \
and int(win.current["my"]) in range(50, int(win.current["h"]-30)):
if win.current["LMB"] and entry in win.story["selected"]:
if int(win.current["LMB"][0]) in range(int(x), int(x+width))\
@ -612,12 +632,9 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty
and int(win.current["my"]) == int(win.previous["LMB"][1]):
if linktype == "file":
if os.path.exists(win.project+"/"+name):
os.system("xdg-open "+win.project+"/"+name)
else:
os.system("xdg-open "+name)
oscalls.file_open(win, name)
else:
elif int(win.current["mx"]) > x+40: # This is a hack. But whatever.
win.url = "assets"
if win.current["LMB"] and win.current["tool"] == "selection":
@ -787,9 +804,28 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty
layer.rectangle(0,0,50, height)
layer.fill()
def after(win, var):
if var:
win.story["links"].append([
"file", var, [
win.current["mx"]-win.story["camera"][0]-75,
win.current["my"]-win.story["camera"][1]-75
]
])
# Now let's select and move the thing
win.story["selected"] = [["file", len(win.story["links"])-1]]
win.current["tool"] = "grab"
win.current["LMB"] = [win.current["mx"], win.current["my"], True]
# Blendfiles
def do():
print("Blendfiles of "+name)
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, SEARCH=name)
UI_elements.roundrect(layer, win,
5,
@ -807,7 +843,9 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty
# References
def do():
print("References of "+name)
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=name+"/reference")
UI_elements.roundrect(layer, win,
5,
@ -823,7 +861,9 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty
# Textures
def do():
print("Textures of "+name)
studio_dialogs.file_select(win, name+"_textures", after, force=True,
IMAGE=True, BLEND=False, VIDEO=True, FILE=False, CHR=True, VEH=True,
LOC=True, OBJ=True, RND=False, FOLDER=False, SEARCH=name+"/tex")
UI_elements.roundrect(layer, win,
5,
@ -839,7 +879,9 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty
# Renders
def do():
print("Renders of "+name)
studio_dialogs.file_select(win, name+"_renders", after, force=True,
IMAGE=True, BLEND=False, VIDEO=True, FILE=False, CHR=True, VEH=True,
LOC=True, OBJ=True, RND=False, FOLDER=False, SEARCH=name+"/renders")
UI_elements.roundrect(layer, win,
5,
@ -889,9 +931,17 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty
if name.endswith(".blend"):
UI_color.set(layer, win, "node_blendfile")
else:
if "ast/" in name:
UI_color.set(layer, win, "node_asset")
elif filetype == "image":
UI_color.set(layer, win, "node_imagefile")
elif filetype == "video":
UI_color.set(layer, win, "node_videofile")
else:
UI_color.set(layer, win, "node_script")
# top banner
@ -916,7 +966,7 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty
else:
if name.endswith(".blend"):
node_dot(outlayer, win, x+width-6, y+120, entry=["blend", name], direction="out")
else:
elif filetype in ["image", "video"]:
node_dot(outlayer, win, x+width-6, y+120, entry=["file", name], direction="out")
else: # If not in the frame
@ -928,3 +978,264 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty
del win.out_dots["file:"+name]
except:
pass
def marker(outlayer, win, name ,x, y ):
# This function will draw markers to the screen. They are like shortcuts in
# a story editor space.
if int(x) in range(int(60), int(win.current["w"]-100))\
and int(y) in range(int(60), int(win.current["h"]-80)):
width = 200
height = 40
inscreen = True
else:
x = min(max(x, 60), win.current["w"]-100)
y = min(max(y, 60), win.current["h"]-80)
width = 40
height = 40
inscreen = False
# Making the layer
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(width), int(height))
layer = cairo.Context(surface)
entry = ["marker", name]
if inscreen:
selected = False
if win.url == "story_editor"\
and int(win.current["mx"]) in range(50, int(win.current["w"]-50)) \
and int(win.current["my"]) in range(50, int(win.current["h"]-30)):
if win.current["LMB"] and entry in win.story["selected"]:
if int(win.current["LMB"][0]) in range(int(x), int(x+40))\
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
if win.current["LMB"] and win.current["tool"] == "selection":
# If mouse over. But way more complex. Because we might select more then
# 1 scene at ones.
mx = win.current["mx"]
my = win.current["my"]
pmx = win.current["LMB"][0]
pmy = win.current["LMB"][1]
intersect = UI_math.rectangle_overlap(
[mx, my, pmx-mx, pmy-my],
[x,y,width, height])
# Now let's make a higlight
if intersect:
selected = True
elif win.previous["LMB"] and win.previous["tool"] == "selection":
# If you released the mouse while selecting. Then do selecting. I guess.
mx = win.previous["mx"]
my = win.previous["my"]
pmx = win.previous["LMB"][0]
pmy = win.previous["LMB"][1]
intersect = UI_math.rectangle_overlap(
[mx, my, pmx-mx, pmy-my],
[x,y,width, height])
# Now let's make a selection
if intersect:
if entry not in win.story["selected"]:
win.story["selected"].append(entry)
# Making it active.
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)
# now let's apply these
win.story["markers"][name][0]\
+= (win.current["mx"] - win.previous["mx"])*mvx
win.story["markers"][name][1]\
+= (win.current["my"] - win.previous["my"])*mvy
if win.current["tool"] == "grab":
try:
if win.current["LMB"]:
x += win.current["mx"] - win.current["LMB"][0]
y += win.current["my"] - win.current["LMB"][1]
elif win.previous["LMB"]:
win.story["markers"][name][0]\
+= win.previous["mx"] - win.previous["LMB"][0]
win.story["markers"][name][1]\
+= win.previous["my"] - win.previous["LMB"][1]
x += win.previous["mx"] - win.previous["LMB"][0]
y += win.previous["my"] - win.previous["LMB"][1]
elif win.current["tool"] != "connect":
win.current["tool"] = "selection"
except:
raise()
# The selected outline
UI_color.set(outlayer, win, "progress_background")
if win.story["active"] == entry:
UI_color.set(outlayer, win, "text_normal")
outlayer.set_line_width(4)
UI_elements.roundrect(outlayer, win,
x,
y,
width,
height,
10,
fill=False)
outlayer.stroke()
outlayer.set_line_width(2)
# Clip
UI_elements.roundrect(layer, win,
0,
0,
width,
height,
10,
fill=False)
layer.clip()
# Background
UI_color.set(layer, win, "dark_overdrop")
layer.rectangle(0,0,width, height)
layer.fill()
# Pin Icon
UI_elements.image(layer, win,
"settings/themes/"+win.settings["Theme"]+"/icons/pin.png",
0, 0, 40, 40)
# Outputting the layer
outlayer.set_source_surface(surface, x, y)
outlayer.paint()
if inscreen:
# Text editor for the marker's name.
UI_elements.text(outlayer, win, name+"_marker",
x+40,
y,
width-40,
40,
set_text=name)
if name != win.text[name+"_marker"]["text"] and win.text[name+"_marker"]["text"]:
def do():
win.story["selected"] = []
win.story["markers"][win.text[name+"_marker"]["text"]] = [
x - win.story["camera"][0],
y - win.story["camera"][1]
]
win.textactive = ""
del win.story["markers"][name]
UI_elements.roundrect(outlayer, win,
x+width-40,
y,
40,
40,
10,
button=do,
icon="ok",
tip=talk.text("checked"))
if 65293 in win.current["keys"]:
do()
else:
if win.textactive == name+"_marker":
win.textactive = ""
def do():
nex = 0-win.story["markers"][name][0] + win.current["w"]/2
ney = 0-win.story["markers"][name][1] + win.current["h"]/2
UI_elements.animate("cameraX", win, win.story["camera"][0],nex, time=20, force=True)
UI_elements.animate("cameraY", win, win.story["camera"][1],ney, time=20, force=True)
UI_elements.roundrect(outlayer, win,
x+width-40,
y,
40,
40,
10,
button=do,
tip=name,
fill=False)
outlayer.stroke()

View file

@ -125,13 +125,13 @@ def layer(win):
for thing in win.story["selected"]:
if thing[0] == "scene":
del win.story["scenes"][thing[1]]
elif thing[0] == "marker":
del win.story["markers"][thing[1]]
elif thing[0] in ["asset", "file"]:
links.append(thing[1])
new = []
print(thing)
for num, i in enumerate(win.story["links"]):

View file

@ -192,12 +192,34 @@ def layer(win):
10,
do,
"node",
talk.text("new_scene_tooltip"),
talk.text("new_scene_tooltip")+"\n[N]",
url="story_editor")
# Shortcut
if 110 in win.current["keys"] and not win.textactive:
do()
win.current["keys"] = []
# Link Asset
def do():
print("Link Asset")
def after(win, var):
print (var)
if var:
win.story["links"].append([
"asset", var, [
win.current["mx"]-win.story["camera"][0]-75,
win.current["my"]-win.story["camera"][1]-75
]
])
# Now let's select and move the thing
win.story["selected"] = [["asset", len(win.story["links"])-1]]
win.current["tool"] = "grab"
win.current["LMB"] = [win.current["mx"], win.current["my"], True]
studio_dialogs.asset_select(win, "new_asset_story", after)
UI_elements.roundrect(layer, win,
5,
@ -207,9 +229,15 @@ def layer(win):
10,
do,
"obj_link",
talk.text("link_asset_tooltip"),
talk.text("link_asset_tooltip")+"\n[L]",
url="story_editor")
# Shortcut
if 108 in win.current["keys"] and not win.textactive:
do()
win.current["keys"] = []
# Link File
def do():
def after(win, var):
@ -221,15 +249,15 @@ def layer(win):
]
])
# Something here breaks the thing IDK what exaclty. I was trying
# to mkae things move. They do not want to. For some reason.
# Now let's select and move the thing
win.story["selected"] = [["file", len(win.story["links"])-1]]
win.current["tool"] = "grab"
win.current["LMB"] = [win.current["mx"], win.current["my"], True]
# win.story["selected"] = [["file", var]]
# win.current["tool"] = "grab"
# win.current["LMB"] = [win.current["mx"], win.current["my"], True]
studio_dialogs.file_select(win, "new_file_story", after, force=True)
studio_dialogs.file_select(win, "new_file_story", after)
UI_elements.roundrect(layer, win,
5,
@ -239,9 +267,15 @@ def layer(win):
10,
do,
"file_link",
talk.text("link_file_tooltip"),
talk.text("link_file_tooltip")+"\n[I]",
url="story_editor")
# Shortcut
if 105 in win.current["keys"] and not win.textactive:
do()
win.current["keys"] = []
# Event
def do():
print("Event")
@ -259,7 +293,29 @@ def layer(win):
# Marker
def do():
print("Marker")
markername = "Marker"
count = 2
while markername in win.story["markers"]:
markername = "Marker_"+str(count)
count = count + 1
win.story["markers"][markername] = [
win.current["mx"]-win.story["camera"][0]+50,
win.current["my"]-win.story["camera"][1]-20
]
win.textactive = markername+"_marker"
win.text[markername+"_marker"] = {
"text" :markername, # Actuall text you are editing.
"cursor":[len(str(markername)),len(str(markername))], # Cursor
"insert":False, # Whether the insert mode is on
"scroll":"markername_scroll" # If multiline. The pointer for the scroll value.
}
win.story["selected"] = [["marker", markername]]
win.current["tool"] = "grab"
win.current["LMB"] = [win.current["mx"], win.current["my"], True]
UI_elements.roundrect(layer, win,
5,
@ -337,10 +393,15 @@ def layer(win):
###### RIGHT PANNEL #######
def select_character(win, var):
print (var)
# Characters
def do():
print("Characters")
studio_dialogs.asset_select(win, "new_asset_story", select_character, force=True, cur="chr")
UI_elements.roundrect(layer, win,
win.current["w"]-45,
@ -355,7 +416,7 @@ def layer(win):
# Vehicles
def do():
print("Vehicles")
studio_dialogs.asset_select(win, "new_asset_story", select_character, force=True, cur="veh")
UI_elements.roundrect(layer, win,
win.current["w"]-45,
@ -370,7 +431,7 @@ def layer(win):
# Locations
def do():
print("Locations")
studio_dialogs.asset_select(win, "new_asset_story", select_character, force=True, cur="loc")
UI_elements.roundrect(layer, win,
win.current["w"]-45,
@ -385,7 +446,7 @@ def layer(win):
# Other (obj)
def do():
print("Other (obj)")
studio_dialogs.asset_select(win, "new_asset_story", select_character, force=True, cur="obj")
UI_elements.roundrect(layer, win,
win.current["w"]-45,
@ -465,16 +526,25 @@ def layer(win):
# Let's prepare the camera first.
# Animation
win.story["camera"][0] = UI_elements.animate("cameraX", win, 0, win.story["camera"][0])
win.story["camera"][1] = UI_elements.animate("cameraY", win, 0, win.story["camera"][1])
cx, cy = win.story["camera"]
if win.url == "story_editor":
if win.current["MMB"]:
win.story["camera"][0] += ( win.current["mx"]-win.previous["mx"])
win.story["camera"][1] += ( win.current["my"]-win.previous["my"])
win.story["camera"][0] -= win.current["scroll"][0]*50
win.story["camera"][1] -= win.current["scroll"][1]*50
cx, cy = win.story["camera"]
if cx != win.story["camera"][0] or cy != win.story["camera"][1]:
UI_elements.animate("cameraX", win, win.story["camera"][0], force=True)
UI_elements.animate("cameraY", win, win.story["camera"][1], force=True)
# EVENTS (Frames)
@ -527,6 +597,26 @@ def layer(win):
studio_nodes.link_node(layer, win, lx, ly, name=linkname, num=num, linktype=linktype )
# Let's put in the start and the end nodes. These are drawn on top of
# everything.
studio_nodes.start_node(layer, win, 60,60,100,40)
studio_nodes.end_node(layer, win, win.current["w"] - 160,
win.current["h"] - 80,
100,40)
# MARKERS
try:
for marker in win.story["markers"]:
mx = win.story["markers"][marker][0] + cx
my = win.story["markers"][marker][1] + cy
studio_nodes.marker(layer, win, marker, mx, my)
except:
pass
# In case there is a selection bug
if not win.story["selected"] and win.current["tool"] != "connect":
win.current["tool"] = "selection"
@ -635,13 +725,7 @@ def layer(win):
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.
studio_nodes.start_node(layer, win, 60,60,100,40)
studio_nodes.end_node(layer, win, win.current["w"] - 160,
win.current["h"] - 80,
100,40)
# Let's draw the line while connecting 2 scenes together.
@ -666,9 +750,30 @@ def layer(win):
pass
# To selected
if 65454 in win.current["keys"] and win.story["selected"] and not win.textactive:
nex = cx-win.szone[0][0] - win.szone[1][0]/2 + win.current["w"]/2
ney = cy-win.szone[0][1] - win.szone[1][1]/2 + win.current["h"]/2
UI_elements.animate("cameraX", win, win.story["camera"][0],nex, force=True)
UI_elements.animate("cameraY", win, win.story["camera"][1],ney, force=True)
# Grab
if 103 in win.current["keys"] and win.story["selected"] and not win.textactive:
win.current["tool"] = "grab"
win.current["LMB"] = [win.current["mx"], win.current["my"], True]
# Scale
if 115 in win.current["keys"] and win.story["selected"] and not win.textactive:
win.current["tool"] = "scale"
win.current["LMB"] = [win.current["mx"], win.current["my"], True]
# Deletion
if 65535 in win.current["keys"] and win.current["tool"] == "selection"\
and win.url == "story_editor" and win.story["selected"]:
and win.url == "story_editor" and win.story["selected"] and not win.textactive:
win.url = "story_deletion_dialog"