| 1 | #include "Layout/ButtonMiiverse.h" |
| 2 | |
| 3 | #include "Library/Controller/InputFunction.h" |
| 4 | #include "Library/Layout/LayoutActionFunction.h" |
| 5 | #include "Library/Layout/LayoutActorUtil.h" |
| 6 | #include "Library/Layout/LayoutInitInfo.h" |
| 7 | #include "Library/Nerve/NerveSetupUtil.h" |
| 8 | #include "Library/Nerve/NerveUtil.h" |
| 9 | |
| 10 | namespace { |
| 11 | NERVE_IMPL(ButtonMiiverse, Wait); |
| 12 | NERVE_IMPL(ButtonMiiverse, Decide); |
| 13 | NERVE_IMPL(ButtonMiiverse, OnWait); |
| 14 | NERVE_IMPL(ButtonMiiverse, Disable); |
| 15 | NERVE_IMPL(ButtonMiiverse, HoldOn); |
| 16 | NERVE_IMPL(ButtonMiiverse, HoldOff); |
| 17 | |
| 18 | NERVES_MAKE_STRUCT(ButtonMiiverse, Wait, Decide, OnWait, Disable, HoldOn, HoldOff); |
| 19 | } // namespace |
| 20 | |
| 21 | ButtonMiiverse::ButtonMiiverse() : al::LayoutActor("Miiverseボタン" ) {} |
| 22 | |
| 23 | void ButtonMiiverse::init(const al::LayoutInitInfo& info) { |
| 24 | al::initLayoutActor(this, info, "ButtonMiiverse" , 0); |
| 25 | initNerve(&NrvButtonMiiverse.Wait, 0); |
| 26 | appear(); |
| 27 | } |
| 28 | |
| 29 | bool ButtonMiiverse::isOn() const { |
| 30 | return al::isNerve(user: this, nerve: &NrvButtonMiiverse.Decide) || |
| 31 | al::isNerve(user: this, nerve: &NrvButtonMiiverse.OnWait); |
| 32 | } |
| 33 | |
| 34 | void ButtonMiiverse::setOff() { |
| 35 | al::setNerve(user: this, nerve: &NrvButtonMiiverse.Wait); |
| 36 | } |
| 37 | |
| 38 | void ButtonMiiverse::validate() { |
| 39 | if (al::isNerve(user: this, nerve: &NrvButtonMiiverse.Disable)) |
| 40 | setOff(); |
| 41 | } |
| 42 | |
| 43 | void ButtonMiiverse::forceValidate() { |
| 44 | setOff(); |
| 45 | } |
| 46 | |
| 47 | void ButtonMiiverse::invalidate() { |
| 48 | if (!al::isNerve(user: this, nerve: &NrvButtonMiiverse.Disable)) |
| 49 | al::setNerve(user: this, nerve: &NrvButtonMiiverse.Disable); |
| 50 | } |
| 51 | |
| 52 | void ButtonMiiverse::exeWait() { |
| 53 | if (al::isFirstStep(user: this)) |
| 54 | al::startAction(layout: this, actionName: "Wait" , paneName: 0); |
| 55 | if (al::isHoldTouchPane(this, "Hit" )) |
| 56 | al::setNerve(user: this, nerve: &NrvButtonMiiverse.HoldOn); |
| 57 | } |
| 58 | |
| 59 | void ButtonMiiverse::exeHoldOn() { |
| 60 | if (al::isFirstStep(user: this)) |
| 61 | al::startAction(layout: this, actionName: "Touch" , paneName: 0); |
| 62 | if (al::isReleaseTouchPane(this, "Hit" )) |
| 63 | al::setNerve(user: this, nerve: &NrvButtonMiiverse.Decide); |
| 64 | else if (!al::isTouchPosInPane(this, "Hit" )) |
| 65 | al::setNerve(user: this, nerve: &NrvButtonMiiverse.HoldOff); |
| 66 | } |
| 67 | |
| 68 | void ButtonMiiverse::exeHoldOff() { |
| 69 | if (al::isFirstStep(user: this)) |
| 70 | al::startAction(layout: this, actionName: "Touch" , paneName: 0); |
| 71 | if (al::isTouchPosInPane(this, "Hit" )) |
| 72 | al::setNerve(user: this, nerve: &NrvButtonMiiverse.HoldOn); |
| 73 | else if (al::isPadReleaseTouch()) |
| 74 | setOff(); |
| 75 | } |
| 76 | |
| 77 | void ButtonMiiverse::exeDecide() { |
| 78 | if (al::isFirstStep(user: this)) |
| 79 | al::startAction(layout: this, actionName: "Decide" , paneName: 0); |
| 80 | al::setNerveAtActionEnd(layout: this, nerve: &NrvButtonMiiverse.OnWait); |
| 81 | } |
| 82 | |
| 83 | void ButtonMiiverse::exeOnWait() { |
| 84 | if (al::isFirstStep(user: this)) |
| 85 | al::startAction(layout: this, actionName: "Wait" , paneName: 0); |
| 86 | } |
| 87 | |
| 88 | void ButtonMiiverse::exeDisable() { |
| 89 | if (al::isFirstStep(user: this)) |
| 90 | al::startAction(layout: this, actionName: "Disable" , paneName: 0); |
| 91 | } |
| 92 | |