summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blc2/functions/chaser.py25
-rw-r--r--blc2/functions/chaserstep.py16
-rw-r--r--interface/__main__.py4
-rwxr-xr-xinterface/chaserview.py8
-rw-r--r--interface/interface.py16
5 files changed, 53 insertions, 16 deletions
diff --git a/blc2/functions/chaser.py b/blc2/functions/chaser.py
index cbf4636..43b9636 100644
--- a/blc2/functions/chaser.py
+++ b/blc2/functions/chaser.py
@@ -264,7 +264,7 @@ class Chaser(Function):
data.steps = [i for i in data.steps if i.start_time+i.actual_duration >= t and i.step.index != -1]
## Render
- lc = {c: 0 for c in self._scope}
+ lc = {c: 0 for c in self.scope}
ac = []
done = []
@@ -282,15 +282,32 @@ class Chaser(Function):
## Handle the lighting demuxing
## First do the fade-finished ones
+ finlc = {}
for slc in done:
for c, v in slc:
- if lc[c] < v:
- lc[c] = v
+ if c not in finlc:
+ finlc[c] = v
+ elif finlc[c] < v:
+ finlc[c] = v
## Now do the fading ones additively
+ fadedlc = {}
for mul, slc in fading:
for c, v in slc:
- lc[c] = min(255, int(v*mul) + lc[c])
+ if c not in finlc:
+ ## Not done fade
+ if c not in fadedlc:
+ fadedlc[c] = min(255, v*mul)
+ else:
+ fadedlc[c] = min(255, fadedlc[c] + v*mul)
+ else:
+ if c not in fadedlc:
+ fadedlc[c] = mul*(v - finlc[c])
+ else:
+ fadedlc[c] = max(fadedlc[c], mul*(v - finlc[c]))
+
+ for c in self.scope:
+ lc[c] = min(255, int((finlc[c] if c in finlc else 0) + (fadedlc[c] if c in fadedlc else 0) + 0.5))
return tuple(lc.items()), ac, data
diff --git a/blc2/functions/chaserstep.py b/blc2/functions/chaserstep.py
index 3d458a1..070f300 100644
--- a/blc2/functions/chaserstep.py
+++ b/blc2/functions/chaserstep.py
@@ -186,6 +186,10 @@ class ChaserStep(Function):
def duration(self):
return self._duration
+ @property
+ def length(self):
+ return self._duration - self.fade_in
+
@duration.setter
def duration(self, value):
if self._duration_mode != MANUAL:
@@ -243,8 +247,8 @@ class ChaserStep(Function):
mul = 1
if t < self.fade_in:
mul *= min(1, t/self.fade_in)
- if fade_start < t <= data.actual_duration:
- mul *= -1*(1 - min(1, (t-fade_start)/self.fade_out))
+ if fade_start <= t <= data.actual_duration:
+ mul *= -1*(1 - min(1, ((t-fade_start)/self.fade_out if self.fade_out != 0 else 0)))
## Render and fade cues
lc, ac, data.data = self._function.render(t, data=data.data)
@@ -260,7 +264,7 @@ class ChaserStep(Function):
e.set("fade-out", str(self.fade_out))
e.set("duration-mode", self.duration_mode)
if self.duration_mode == MANUAL:
- e.set("duration", str(self.duration))
+ e.set("duration", str(self.length))
if self._function is not None:
e.set("function", str(self._function.id))
@@ -292,8 +296,8 @@ class ChaserStep(Function):
else:
duration = int(duration)
- function = int(e.get("function"))
+ function = cls.int_or_none(e.get("function"))
return cls(c, id_=id_, name=name, fade_in=fade_in, fade_out=fade_out,
- function=w.functions[function], duration_mode=duration_mode,
- duration=duration)
+ function=(w.functions[function] if function is not None else None),
+ duration_mode=duration_mode, duration=duration)
diff --git a/interface/__main__.py b/interface/__main__.py
index b2f45fe..878b263 100644
--- a/interface/__main__.py
+++ b/interface/__main__.py
@@ -4,9 +4,9 @@ import sys
from .interface import Interface
from .ola import OLAOutput
-from .dummy import DummyOutput
+#from .dummy import DummyOutput
if len(sys.argv) > 2:
raise ValueError("Usage: %s [workspace file]" % sys.argv[0])
-Interface(sys.argv[1] if len(sys.argv) == 2 else None, DummyOutput()).main()
+Interface(sys.argv[1] if len(sys.argv) == 2 else None, OLAOutput()).main()
diff --git a/interface/chaserview.py b/interface/chaserview.py
index 2c94240..011d2bd 100755
--- a/interface/chaserview.py
+++ b/interface/chaserview.py
@@ -83,9 +83,11 @@ class ChaserView:
self.win.addstr(1, 1, self.fit(("%d: "% c.id) + c.name + " (%s)" % ("Join" if c.type == JOIN else c.advance_mode), w, True), curses.A_REVERSE if self._highlight else 0)
maxsteps = self._height - 4
+ first = 0
if maxsteps < len(c.steps):
if self._selected is None:
- steps = c.steps[:maxsteps]
+ first = 0
+ last = maxsteps
else:
last = min(self._selected + (maxsteps // 2), len(c.steps))
first = last - maxsteps
@@ -111,11 +113,11 @@ class ChaserView:
ft = "-"
fid = "---"
- t = "%s%3s%s|%s:%s:%s" % (ft, fid, '*' if (s.type == CHASERSTEP and s.duration_mode == MANUAL) else ' ', format_time(s.fade_in), format_time(s.duration), format_time(s.fade_out))
+ t = "%s%3s%s|%s:%s:%s" % (ft, fid, '*' if (s.type == CHASERSTEP and s.duration_mode == MANUAL) else ' ', format_time(s.fade_in), format_time(s.duration if s.type != CHASERSTEP else s.length), format_time(s.fade_out))
self.win.addstr(n+2, 1, self.fit((self._numformat % (first+n)) + ": " + s.name, w-len(t), pad=True)+t, attrs)
if first > 0:
- self.win.addch(3, self._width//2, '⯅')
+ self.win.addch(2, self._width//2, '⯅')
if last < len(c.steps):
self.win.addch(self._height-1, self._width//2, '⯆')
diff --git a/interface/interface.py b/interface/interface.py
index 500728c..832663e 100644
--- a/interface/interface.py
+++ b/interface/interface.py
@@ -563,7 +563,7 @@ class Interface:
if fid not in self.w.functions:
return "No such function"
f = self.w.functions[fid]
- if f.type not in (SCENE, AUDIO, CHASER):
+ if f.type not in (SCENE, AUDIO, CHASER, JOIN):
return "Invalid function"
s.function = f
@@ -725,6 +725,17 @@ class Interface:
self.current_cv.chaser.advance_mode = mode
self.current_cv.set_chaser(self.current_cv.chaser, self.current_cv.selected)
+ def base_copy(self, num, name=None):
+ with self.w_lock:
+ ## TODO: Implement this in BLC
+ if num not in self.w.functions:
+ return "No such function"
+ f = self.w.functions[num]
+ if f.type != SCENE:
+ return "Can only close scenes"
+ f2 = Scene(self.w, name=name, values=f.values)
+ self.handle_enter(f2.id)
+
def __init__(self, path, output):
## Have to do most of the actual initialization in the main method, as curses isn't
## ready yet.
@@ -775,6 +786,9 @@ class Interface:
("list audio", lambda: self.list_functions(AUDIO)),
("list joins", lambda: self.list_functions(JOIN)),
+ ("copy $num", self.base_copy),
+ ("copy $num $quoted_string", self.base_copy),
+
("currentstatus", self.current_status),
("pager page", self.page),