| 1 | #include "Layout/MiniGameLayout.h" |
| 2 | |
| 3 | #include "Library/Layout/LayoutActionFunction.h" |
| 4 | #include "Library/Layout/LayoutActorUtil.h" |
| 5 | #include "Library/Layout/LayoutInitInfo.h" |
| 6 | #include "Library/Message/MessageHolder.h" |
| 7 | #include "Library/Nerve/NerveSetupUtil.h" |
| 8 | #include "Library/Nerve/NerveUtil.h" |
| 9 | |
| 10 | #include "Layout/KidsModeLayoutAccessor.h" |
| 11 | |
| 12 | namespace { |
| 13 | NERVE_IMPL(MiniGameLayout, Appear); |
| 14 | NERVE_IMPL(MiniGameLayout, End); |
| 15 | NERVE_IMPL(MiniGameLayout, Wait); |
| 16 | |
| 17 | NERVES_MAKE_NOSTRUCT(MiniGameLayout, Wait, End, Appear); |
| 18 | } // namespace |
| 19 | |
| 20 | MiniGameLayout::MiniGameLayout(const char* name, const al::LayoutInitInfo& info) |
| 21 | : al::LayoutActor(name) { |
| 22 | al::initLayoutActor(this, info, "MiniGame" , nullptr); |
| 23 | initNerve(&Appear, 0); |
| 24 | kill(); |
| 25 | } |
| 26 | |
| 27 | void MiniGameLayout::appear() { |
| 28 | al::LayoutActor::appear(); |
| 29 | rs::setKidsModeLayoutDisable(this); |
| 30 | } |
| 31 | |
| 32 | void MiniGameLayout::kill() { |
| 33 | al::LayoutActor::kill(); |
| 34 | rs::setKidsModeLayoutEnable(this); |
| 35 | } |
| 36 | |
| 37 | void MiniGameLayout::startJumprope() { |
| 38 | al::setPaneString(this, "TxtTitle" , |
| 39 | al::getSystemMessageString(this, "MiniGame" , "TitleJumprope" ), 0); |
| 40 | al::startAction(layout: this, actionName: "Jumprope" , paneName: "State" ); |
| 41 | startNewRecordWait(); |
| 42 | al::setNerve(user: this, nerve: &Appear); |
| 43 | appear(); |
| 44 | } |
| 45 | |
| 46 | void MiniGameLayout::startRace() { |
| 47 | al::setPaneString(this, "TxtTitle" , |
| 48 | al::getSystemMessageString(this, "MiniGame" , "TitleRaceManRace" ), 0); |
| 49 | al::startAction(layout: this, actionName: "Runrace" , paneName: "State" ); |
| 50 | startNewRecordWait(); |
| 51 | al::setNerve(user: this, nerve: &Appear); |
| 52 | appear(); |
| 53 | } |
| 54 | |
| 55 | void MiniGameLayout::startVolleyball() { |
| 56 | al::setPaneString(this, "TxtTitle" , |
| 57 | al::getSystemMessageString(this, "MiniGame" , "TitleVolleyball" ), 0); |
| 58 | al::startAction(layout: this, actionName: "Volleyball" , paneName: "State" ); |
| 59 | startNewRecordWait(); |
| 60 | al::setNerve(user: this, nerve: &Appear); |
| 61 | appear(); |
| 62 | } |
| 63 | |
| 64 | void MiniGameLayout::end() { |
| 65 | al::setNerve(user: this, nerve: &End); |
| 66 | } |
| 67 | |
| 68 | void MiniGameLayout::setBestCount(s32 count) { |
| 69 | al::replaceMessageTagScore( |
| 70 | &mScoreText, this, al::getSystemMessageString(this, "MiniGame" , "Counter" ), count, "Score" ); |
| 71 | al::setPaneString(this, "TxtBestRecord" , mScoreText.cstr(), 0); |
| 72 | } |
| 73 | |
| 74 | void MiniGameLayout::setTodayCount(s32 count) { |
| 75 | al::replaceMessageTagScore( |
| 76 | &mScoreText, this, al::getSystemMessageString(this, "MiniGame" , "Counter" ), count, "Score" ); |
| 77 | al::setPaneString(this, "TxtBestRecordToday" , mScoreText.cstr(), 0); |
| 78 | } |
| 79 | |
| 80 | void MiniGameLayout::setCount(s32 count) { |
| 81 | al::replaceMessageTagScore( |
| 82 | &mScoreText, this, al::getSystemMessageString(this, "MiniGame" , "Counter" ), count, "Score" ); |
| 83 | al::setPaneString(this, "TxtRecord" , mScoreText.cstr(), 0); |
| 84 | } |
| 85 | |
| 86 | void MiniGameLayout::startNewRecord() { |
| 87 | al::startAction(layout: this, actionName: "NewRecord" , paneName: "NewRecord" ); |
| 88 | } |
| 89 | |
| 90 | void MiniGameLayout::startNewRecordWait() { |
| 91 | al::startAction(layout: this, actionName: "NewRecordWait" , paneName: "NewRecord" ); |
| 92 | } |
| 93 | |
| 94 | void MiniGameLayout::startNewRecordToday() { |
| 95 | al::startAction(layout: this, actionName: "NewRecordToday" , paneName: "NewRecord" ); |
| 96 | } |
| 97 | |
| 98 | bool MiniGameLayout::isEnd() const { |
| 99 | return al::isNerve(user: this, nerve: &End); |
| 100 | } |
| 101 | |
| 102 | void MiniGameLayout::exeAppear() { |
| 103 | if (al::isFirstStep(user: this)) |
| 104 | al::startAction(layout: this, actionName: "Appear" , paneName: nullptr); |
| 105 | if (al::isActionEnd(layout: this, paneName: nullptr)) |
| 106 | al::setNerve(user: this, nerve: &Wait); |
| 107 | } |
| 108 | |
| 109 | void MiniGameLayout::exeWait() { |
| 110 | if (al::isFirstStep(user: this)) |
| 111 | al::startAction(layout: this, actionName: "Wait" , paneName: nullptr); |
| 112 | } |
| 113 | |
| 114 | void MiniGameLayout::exeEnd() { |
| 115 | if (al::isFirstStep(user: this)) |
| 116 | al::startAction(layout: this, actionName: "End" , paneName: nullptr); |
| 117 | if (al::isActionEnd(layout: this, paneName: nullptr)) |
| 118 | kill(); |
| 119 | } |
| 120 | |