Add a show compiler so QLC+ workspaces can be described and tested.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
fee1985e1a
commit
4374ffb430
14 files changed
+3739
No files matched your search
@@ -0,0 +1,48 @@
|
||||
"""Serialize a Show to a QLC+ 4.12 workspace."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .model import Show, Universe, fixture_xml, group_xml, universe_xml
|
||||
|
||||
|
||||
def render_show(show: Show) -> str:
|
||||
universes = list(show.universes) or [Universe(i, f"Universe {i + 1}") for i in range(4)]
|
||||
universes.sort(key=lambda uni: uni.id)
|
||||
width, height = show.size()
|
||||
engine = [" <InputOutputMap>"]
|
||||
engine.extend(universe_xml(uni) for uni in universes)
|
||||
engine.append(" </InputOutputMap>")
|
||||
engine.extend(fixture_xml(fx) for fx in show.fixtures)
|
||||
engine.extend(group_xml(group) for group in show.groups)
|
||||
engine.extend(fn.render() for fn in show.functions)
|
||||
widgets = show.vc.render(" ")
|
||||
return (
|
||||
'<?xml version="1.0" encoding="UTF-8"?>\n'
|
||||
"<!DOCTYPE Workspace>\n"
|
||||
'<Workspace xmlns="http://www.qlcplus.org/Workspace" CurrentWindow="VirtualConsole">\n'
|
||||
" <Creator>\n"
|
||||
" <Name>Q Light Controller Plus</Name>\n"
|
||||
f" <Version>{show.version}</Version>\n"
|
||||
f" <Author>{_author(show.author)}</Author>\n"
|
||||
" </Creator>\n"
|
||||
" <Engine>\n"
|
||||
+ "\n".join(engine)
|
||||
+ "\n </Engine>\n"
|
||||
" <VirtualConsole>\n"
|
||||
+ widgets
|
||||
+ "\n <Properties>\n"
|
||||
f' <Size Width="{width}" Height="{height}"/>\n'
|
||||
' <GrandMaster ChannelMode="Intensity" ValueMode="Reduce" SliderMode="Normal"/>\n'
|
||||
" </Properties>\n"
|
||||
" </VirtualConsole>\n"
|
||||
" <SimpleDesk>\n"
|
||||
" <Engine/>\n"
|
||||
" </SimpleDesk>\n"
|
||||
"</Workspace>\n"
|
||||
)
|
||||
|
||||
|
||||
def _author(name: str) -> str:
|
||||
from .xmlutil import text
|
||||
|
||||
return text(name)
|
||||
Reference in new issue
Block a user