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
10namespace {
11NERVE_IMPL(ButtonMiiverse, Wait);
12NERVE_IMPL(ButtonMiiverse, Decide);
13NERVE_IMPL(ButtonMiiverse, OnWait);
14NERVE_IMPL(ButtonMiiverse, Disable);
15NERVE_IMPL(ButtonMiiverse, HoldOn);
16NERVE_IMPL(ButtonMiiverse, HoldOff);
17
18NERVES_MAKE_STRUCT(ButtonMiiverse, Wait, Decide, OnWait, Disable, HoldOn, HoldOff);
19} // namespace
20
21ButtonMiiverse::ButtonMiiverse() : al::LayoutActor("Miiverseボタン") {}
22
23void ButtonMiiverse::init(const al::LayoutInitInfo& info) {
24 al::initLayoutActor(this, info, "ButtonMiiverse", 0);
25 initNerve(&NrvButtonMiiverse.Wait, 0);
26 appear();
27}
28
29bool ButtonMiiverse::isOn() const {
30 return al::isNerve(user: this, nerve: &NrvButtonMiiverse.Decide) ||
31 al::isNerve(user: this, nerve: &NrvButtonMiiverse.OnWait);
32}
33
34void ButtonMiiverse::setOff() {
35 al::setNerve(user: this, nerve: &NrvButtonMiiverse.Wait);
36}
37
38void ButtonMiiverse::validate() {
39 if (al::isNerve(user: this, nerve: &NrvButtonMiiverse.Disable))
40 setOff();
41}
42
43void ButtonMiiverse::forceValidate() {
44 setOff();
45}
46
47void ButtonMiiverse::invalidate() {
48 if (!al::isNerve(user: this, nerve: &NrvButtonMiiverse.Disable))
49 al::setNerve(user: this, nerve: &NrvButtonMiiverse.Disable);
50}
51
52void 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
59void 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
68void 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
77void 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
83void ButtonMiiverse::exeOnWait() {
84 if (al::isFirstStep(user: this))
85 al::startAction(layout: this, actionName: "Wait", paneName: 0);
86}
87
88void ButtonMiiverse::exeDisable() {
89 if (al::isFirstStep(user: this))
90 al::startAction(layout: this, actionName: "Disable", paneName: 0);
91}
92