| 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 | |
| 9 | namespace { |
| 10 | using namespace al; |
| 11 | NERVE_IMPL(WipeSimple, Close); |
| 12 | NERVE_IMPL(WipeSimple, CloseEnd); |
| 13 | NERVE_IMPL(WipeSimple, Open); |
| 14 | |
| 15 | NERVES_MAKE_NOSTRUCT(WipeSimple, Open); |
| 16 | NERVES_MAKE_STRUCT(WipeSimple, Close, CloseEnd); |
| 17 | } // namespace |
| 18 | |
| 19 | namespace al { |
| 20 | |
| 21 | WipeSimple::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 | |
| 28 | void 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 | |
| 41 | void WipeSimple::tryStartClose(s32 frames) { |
| 42 | if (isOpenEnd() || (!isNerve(user: this, nerve: &NrvWipeSimple.Close) && !isCloseEnd())) |
| 43 | startClose(frames); |
| 44 | } |
| 45 | |
| 46 | void WipeSimple::startCloseEnd() { |
| 47 | startAction(layout: this, actionName: "Wait" , paneName: nullptr); |
| 48 | LayoutActor::appear(); |
| 49 | setNerve(user: this, nerve: &NrvWipeSimple.CloseEnd); |
| 50 | } |
| 51 | |
| 52 | void WipeSimple::startOpen(s32 frames) { |
| 53 | mFrames = frames; |
| 54 | startAction(layout: this, actionName: "End" , paneName: nullptr); |
| 55 | setNerve(user: this, nerve: &Open); |
| 56 | } |
| 57 | |
| 58 | void WipeSimple::tryStartOpen(s32 frames) { |
| 59 | if (!isOpenEnd() && !isNerve(user: this, nerve: &Open)) |
| 60 | startOpen(frames); |
| 61 | } |
| 62 | |
| 63 | bool WipeSimple::isCloseEnd() const { |
| 64 | return isNerve(user: this, nerve: &NrvWipeSimple.CloseEnd); |
| 65 | } |
| 66 | |
| 67 | bool WipeSimple::isOpenEnd() const { |
| 68 | return !isAlive(); |
| 69 | } |
| 70 | |
| 71 | void WipeSimple::exeClose() { |
| 72 | if (!isFirstStep(user: this) && isActionEnd(layout: this, paneName: nullptr)) |
| 73 | setNerve(user: this, nerve: &NrvWipeSimple.CloseEnd); |
| 74 | } |
| 75 | |
| 76 | void WipeSimple::exeCloseEnd() { |
| 77 | if (isFirstStep(user: this)) |
| 78 | startAction(layout: this, actionName: "Wait" , paneName: nullptr); |
| 79 | } |
| 80 | |
| 81 | void 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 | |
| 92 | void WipeSimple::appear() { |
| 93 | LayoutActor::appear(); |
| 94 | } |
| 95 | |
| 96 | } // namespace al |
| 97 | |