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
12namespace {
13NERVE_IMPL(MiniGameLayout, Appear);
14NERVE_IMPL(MiniGameLayout, End);
15NERVE_IMPL(MiniGameLayout, Wait);
16
17NERVES_MAKE_NOSTRUCT(MiniGameLayout, Wait, End, Appear);
18} // namespace
19
20MiniGameLayout::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
27void MiniGameLayout::appear() {
28 al::LayoutActor::appear();
29 rs::setKidsModeLayoutDisable(this);
30}
31
32void MiniGameLayout::kill() {
33 al::LayoutActor::kill();
34 rs::setKidsModeLayoutEnable(this);
35}
36
37void 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
46void 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
55void 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
64void MiniGameLayout::end() {
65 al::setNerve(user: this, nerve: &End);
66}
67
68void 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
74void 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
80void 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
86void MiniGameLayout::startNewRecord() {
87 al::startAction(layout: this, actionName: "NewRecord", paneName: "NewRecord");
88}
89
90void MiniGameLayout::startNewRecordWait() {
91 al::startAction(layout: this, actionName: "NewRecordWait", paneName: "NewRecord");
92}
93
94void MiniGameLayout::startNewRecordToday() {
95 al::startAction(layout: this, actionName: "NewRecordToday", paneName: "NewRecord");
96}
97
98bool MiniGameLayout::isEnd() const {
99 return al::isNerve(user: this, nerve: &End);
100}
101
102void 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
109void MiniGameLayout::exeWait() {
110 if (al::isFirstStep(user: this))
111 al::startAction(layout: this, actionName: "Wait", paneName: nullptr);
112}
113
114void 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