1#include "Library/Play/Layout/WipeSimple.h"
2
3#include "Library/Layout/LayoutActionFunction.h"
4#include "Library/Layout/LayoutActor.h"
5#include "Library/Layout/LayoutInitInfo.h"
6#include "Library/Nerve/NerveSetupUtil.h"
7#include "Library/Nerve/NerveUtil.h"
8
9namespace {
10using namespace al;
11NERVE_IMPL(WipeSimple, Close);
12NERVE_IMPL(WipeSimple, CloseEnd);
13NERVE_IMPL(WipeSimple, Open);
14
15NERVES_MAKE_NOSTRUCT(WipeSimple, Open);
16NERVES_MAKE_STRUCT(WipeSimple, Close, CloseEnd);
17} // namespace
18
19namespace al {
20
21WipeSimple::WipeSimple(const char* name, const char* layoutName, const LayoutInitInfo& info,
22 const char* actorName)
23 : LayoutActor(name) {
24 initLayoutActor(this, info, layoutName, actorName);
25 initNerve(&NrvWipeSimple.Close, 0);
26}
27
28void WipeSimple::startClose(s32 frames) {
29 mFrames = frames;
30 startAction(layout: this, actionName: "Appear", paneName: nullptr);
31 LayoutActor::appear();
32
33 if (mFrames <= 0)
34 setActionFrameRate(layout: this, frameRate: 1.0f, paneName: nullptr);
35 else
36 setActionFrameRate(layout: this, frameRate: getActionFrameMax(layout: this, actionName: "Appear", paneName: nullptr) / mFrames, paneName: nullptr);
37
38 setNerve(user: this, nerve: &NrvWipeSimple.Close);
39}
40
41void WipeSimple::tryStartClose(s32 frames) {
42 if (isOpenEnd() || (!isNerve(user: this, nerve: &NrvWipeSimple.Close) && !isCloseEnd()))
43 startClose(frames);
44}
45
46void WipeSimple::startCloseEnd() {
47 startAction(layout: this, actionName: "Wait", paneName: nullptr);
48 LayoutActor::appear();
49 setNerve(user: this, nerve: &NrvWipeSimple.CloseEnd);
50}
51
52void WipeSimple::startOpen(s32 frames) {
53 mFrames = frames;
54 startAction(layout: this, actionName: "End", paneName: nullptr);
55 setNerve(user: this, nerve: &Open);
56}
57
58void WipeSimple::tryStartOpen(s32 frames) {
59 if (!isOpenEnd() && !isNerve(user: this, nerve: &Open))
60 startOpen(frames);
61}
62
63bool WipeSimple::isCloseEnd() const {
64 return isNerve(user: this, nerve: &NrvWipeSimple.CloseEnd);
65}
66
67bool WipeSimple::isOpenEnd() const {
68 return !isAlive();
69}
70
71void WipeSimple::exeClose() {
72 if (!isFirstStep(user: this) && isActionEnd(layout: this, paneName: nullptr))
73 setNerve(user: this, nerve: &NrvWipeSimple.CloseEnd);
74}
75
76void WipeSimple::exeCloseEnd() {
77 if (isFirstStep(user: this))
78 startAction(layout: this, actionName: "Wait", paneName: nullptr);
79}
80
81void WipeSimple::exeOpen() {
82 if (isFirstStep(user: this)) {
83 if (mFrames <= 0)
84 setActionFrameRate(layout: this, frameRate: 1.0f, paneName: nullptr);
85 else
86 setActionFrameRate(layout: this, frameRate: getActionFrameMax(layout: this, actionName: "End", paneName: nullptr) / mFrames, paneName: nullptr);
87 }
88 if (isActionEnd(layout: this, paneName: nullptr))
89 kill();
90}
91
92void WipeSimple::appear() {
93 LayoutActor::appear();
94}
95
96} // namespace al
97