[add] Added PostEffectController.
This commit is contained in:
parent
2fd5736587
commit
1e6ebe97ce
@ -79,7 +79,7 @@ struct ActorControllerFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@property ActorController product() {
|
@property ActorController product() out (r; r) {
|
||||||
return product_;
|
return product_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@ import sjplayer.Actor,
|
|||||||
sjplayer.ElementDrawerInterface,
|
sjplayer.ElementDrawerInterface,
|
||||||
sjplayer.ElementInterface,
|
sjplayer.ElementInterface,
|
||||||
sjplayer.PostEffect,
|
sjplayer.PostEffect,
|
||||||
|
sjplayer.PostEffectController,
|
||||||
|
sjplayer.PostEffectControllerInterface,
|
||||||
sjplayer.ProgramSet,
|
sjplayer.ProgramSet,
|
||||||
sjplayer.ScheduledControllerInterface,
|
sjplayer.ScheduledControllerInterface,
|
||||||
sjplayer.VarStore;
|
sjplayer.VarStore;
|
||||||
@ -40,6 +42,11 @@ class Context {
|
|||||||
"actor",
|
"actor",
|
||||||
ActorControllerFactory(varstore, actor_),
|
ActorControllerFactory(varstore, actor_),
|
||||||
),
|
),
|
||||||
|
tuple(
|
||||||
|
"posteffect",
|
||||||
|
PostEffectControllerFactory(varstore, posteffect_),
|
||||||
|
),
|
||||||
|
|
||||||
tuple(
|
tuple(
|
||||||
"background",
|
"background",
|
||||||
BackgroundScheduledControllerFactory(varstore, background_),
|
BackgroundScheduledControllerFactory(varstore, background_),
|
||||||
@ -58,12 +65,11 @@ class Context {
|
|||||||
drawers_ = builder.drawers[];
|
drawers_ = builder.drawers[];
|
||||||
controllers_ = builder.controllers[];
|
controllers_ = builder.controllers[];
|
||||||
|
|
||||||
actor_controller_ = factories[0][1].product;
|
actor_controller_ = factories[0][1].product;
|
||||||
|
posteffect_controller_ = factories[1][1].product;
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
~this() {
|
~this() {
|
||||||
actor_controller_.destroy();
|
|
||||||
|
|
||||||
controllers_.each!destroy;
|
controllers_.each!destroy;
|
||||||
drawers_.each!destroy;
|
drawers_.each!destroy;
|
||||||
elements_.each!destroy;
|
elements_.each!destroy;
|
||||||
@ -109,6 +115,10 @@ class Context {
|
|||||||
@property inout(ActorControllerInterface) actor() inout {
|
@property inout(ActorControllerInterface) actor() inout {
|
||||||
return actor_controller_;
|
return actor_controller_;
|
||||||
}
|
}
|
||||||
|
///
|
||||||
|
@property inout(PostEffectControllerInterface) posteffect() inout {
|
||||||
|
return posteffect_controller_;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Builder : ContextBuilderInterface {
|
class Builder : ContextBuilderInterface {
|
||||||
@ -135,5 +145,6 @@ class Context {
|
|||||||
ElementDrawerInterface[] drawers_;
|
ElementDrawerInterface[] drawers_;
|
||||||
ScheduledControllerInterface[] controllers_;
|
ScheduledControllerInterface[] controllers_;
|
||||||
|
|
||||||
ActorControllerInterface actor_controller_;
|
ActorControllerInterface actor_controller_;
|
||||||
|
PostEffectControllerInterface posteffect_controller_;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ class PostEffect {
|
|||||||
///
|
///
|
||||||
align(1) vec2 clip_lefttop = vec2(1, 1);
|
align(1) vec2 clip_lefttop = vec2(1, 1);
|
||||||
///
|
///
|
||||||
align(1) vec2 clip_righttop = vec2(1, 1);
|
align(1) vec2 clip_rightbottom = vec2(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -62,7 +62,9 @@ class PostEffect {
|
|||||||
program_.Draw(tex_, sampler_, instance, size_);
|
program_.Draw(tex_, sampler_, instance, size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
Instance instance;
|
Instance instance;
|
||||||
|
alias instance this;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const vec2i size_;
|
const vec2i size_;
|
||||||
|
74
sjplayer/src/sjplayer/PostEffectController.d
Normal file
74
sjplayer/src/sjplayer/PostEffectController.d
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/// License: MIT
|
||||||
|
module sjplayer.PostEffectController;
|
||||||
|
|
||||||
|
import std.range.primitives;
|
||||||
|
|
||||||
|
import sjscript;
|
||||||
|
|
||||||
|
import sjplayer.AbstractScheduledController,
|
||||||
|
sjplayer.ContextBuilderInterface,
|
||||||
|
sjplayer.PostEffect,
|
||||||
|
sjplayer.PostEffectControllerInterface,
|
||||||
|
sjplayer.ScheduledController,
|
||||||
|
sjplayer.VarStoreInterface;
|
||||||
|
|
||||||
|
///
|
||||||
|
class PostEffectController : PostEffectScheduledController, PostEffectControllerInterface {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
this(
|
||||||
|
PostEffect posteffect,
|
||||||
|
in VarStoreInterface varstore,
|
||||||
|
in ParametersBlock[] operations) {
|
||||||
|
super(posteffect, varstore, operations);
|
||||||
|
posteffect_ = posteffect;
|
||||||
|
}
|
||||||
|
|
||||||
|
override void CauseDamagedEffect() {
|
||||||
|
}
|
||||||
|
override void Update() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
PostEffect posteffect_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private alias PostEffectScheduledController = ScheduledController!(
|
||||||
|
PostEffect,
|
||||||
|
[
|
||||||
|
"clip_left": "clip_lefttop.x",
|
||||||
|
"clip_top": "clip_lefttop.y",
|
||||||
|
"clip_right": "clip_rightbottom.x",
|
||||||
|
"clip_bottom": "clip_rightbottom.y",
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
///
|
||||||
|
struct PostEffectControllerFactory {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
this(in VarStoreInterface varstore, PostEffect posteffect) {
|
||||||
|
varstore_ = varstore;
|
||||||
|
posteffect_ = posteffect;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
void Create(R)(R params, ContextBuilderInterface builder)
|
||||||
|
if (isInputRange!R && is(ElementType!R == ParametersBlock)) {
|
||||||
|
product_ = new PostEffectController(
|
||||||
|
posteffect_, varstore_, SortParametersBlock(params));
|
||||||
|
builder.AddScheduledController(product_);
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
@property PostEffectController product() out (r; r) {
|
||||||
|
return product_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const VarStoreInterface varstore_;
|
||||||
|
|
||||||
|
PostEffect posteffect_;
|
||||||
|
|
||||||
|
PostEffectController product_;
|
||||||
|
}
|
11
sjplayer/src/sjplayer/PostEffectControllerInterface.d
Normal file
11
sjplayer/src/sjplayer/PostEffectControllerInterface.d
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/// License: MIT
|
||||||
|
module sjplayer.PostEffectControllerInterface;
|
||||||
|
|
||||||
|
///
|
||||||
|
interface PostEffectControllerInterface {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
void CauseDamagedEffect();
|
||||||
|
///
|
||||||
|
void Update();
|
||||||
|
}
|
@ -39,6 +39,7 @@ int main(string[] args) {
|
|||||||
|
|
||||||
context.OperateScheduledControllers(beat);
|
context.OperateScheduledControllers(beat);
|
||||||
context.actor.Update();
|
context.actor.Update();
|
||||||
|
context.posteffect.Update();
|
||||||
|
|
||||||
context.StartDrawing();
|
context.StartDrawing();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user