[update] Implemented creating Context for sjplayer.

This commit is contained in:
falsycat 2019-10-06 00:00:00 +00:00
parent 4979b7f8fa
commit e1eac4cf85
2 changed files with 27 additions and 4 deletions

View File

@ -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;

View File

@ -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);
} }