[update] Implemented creating Context for sjplayer
.
This commit is contained in:
parent
4979b7f8fa
commit
e1eac4cf85
@ -1,10 +1,15 @@
|
|||||||
/// License: MIT
|
/// License: MIT
|
||||||
module sjplayer.Context;
|
module sjplayer.Context;
|
||||||
|
|
||||||
import std.algorithm;
|
import std.algorithm,
|
||||||
|
std.typecons;
|
||||||
|
|
||||||
|
import sjscript;
|
||||||
|
|
||||||
import sjplayer.ElementInterface,
|
import sjplayer.ElementInterface,
|
||||||
sjplayer.ScheduledControllerInterface;
|
sjplayer.ElementProgramSet,
|
||||||
|
sjplayer.ScheduledControllerInterface,
|
||||||
|
sjplayer.VarStoreInterface;
|
||||||
|
|
||||||
///
|
///
|
||||||
struct Context {
|
struct Context {
|
||||||
@ -12,6 +17,25 @@ struct Context {
|
|||||||
@disable this();
|
@disable this();
|
||||||
@disable this(this);
|
@disable this(this);
|
||||||
|
|
||||||
|
///
|
||||||
|
this(ParametersBlock[] params, ElementProgramSet programs) {
|
||||||
|
auto varstore = new BlackHole!VarStoreInterface;
|
||||||
|
|
||||||
|
import sjplayer.CircleElementScheduledController;
|
||||||
|
auto factories = tuple(
|
||||||
|
tuple(
|
||||||
|
"circle",
|
||||||
|
CircleElementScheduledControllerFactory(programs, varstore),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
foreach (factory; factories) {
|
||||||
|
auto result = factory[1].
|
||||||
|
Create(params.filter!(x => x.name == factory[0]));
|
||||||
|
elements_ ~= result.elements;
|
||||||
|
drawers_ ~= result.drawer;
|
||||||
|
controllers_ ~= result.controllers;
|
||||||
|
}
|
||||||
|
}
|
||||||
///
|
///
|
||||||
~this() {
|
~this() {
|
||||||
controllers_.each!destroy;
|
controllers_.each!destroy;
|
||||||
|
@ -15,6 +15,5 @@ Context CreateContextFromText(string src, ElementProgramSet programs) {
|
|||||||
///
|
///
|
||||||
Context CreateContextFromScriptAst(
|
Context CreateContextFromScriptAst(
|
||||||
ParametersBlock[] params, ElementProgramSet programs) {
|
ParametersBlock[] params, ElementProgramSet programs) {
|
||||||
// TODO:
|
return Context(params, programs);
|
||||||
assert(false);
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user