1#include "Layout/SimpleLayoutMenu.h"
2
3#include "Library/Layout/LayoutActionFunction.h"
4#include "Library/Layout/LayoutInitInfo.h"
5#include "Library/Nerve/NerveSetupUtil.h"
6#include "Library/Nerve/NerveUtil.h"
7
8namespace {
9NERVE_HOST_TYPE_IMPL(SimpleLayoutMenu, Appear);
10NERVE_HOST_TYPE_IMPL(SimpleLayoutMenu, Wait);
11NERVE_HOST_TYPE_IMPL(SimpleLayoutMenu, End);
12NERVE_HOST_TYPE_IMPL(SimpleLayoutMenu, EndWait);
13
14NERVES_MAKE_STRUCT(HostType, Appear, End, EndWait, Wait);
15} // namespace
16
17SimpleLayoutMenu::SimpleLayoutMenu(const char* name, const char* layoutName,
18 const al::LayoutInitInfo& info, const char* archiveName,
19 bool localize)
20 : al::LayoutActor(name) {
21 if (localize)
22 al::initLayoutActorLocalized(this, info, layoutName, archiveName);
23 else
24 al::initLayoutActor(this, info, layoutName, archiveName);
25
26 initNerve(&NrvHostType.Appear, 0);
27}
28
29SimpleLayoutMenu::SimpleLayoutMenu(al::LayoutActor* parent, const char* name,
30 const char* layoutName, const al::LayoutInitInfo& info,
31 const char* archiveName)
32 : al::LayoutActor(name) {
33 al::initLayoutPartsActor(this, parent, info, layoutName, archiveName);
34 initNerve(&NrvHostType.Appear, 0);
35}
36
37void SimpleLayoutMenu::startAppear(const char* actionName) {
38 al::startAction(layout: this, actionName, paneName: nullptr);
39 al::LayoutActor::appear();
40 setNerve(user: this, nerve: &NrvHostType.Appear);
41}
42
43void SimpleLayoutMenu::startEnd(const char* actionName) {
44 if (al::isNerve(user: this, nerve: &NrvHostType.End) || isEndWait())
45 return;
46 al::startAction(layout: this, actionName, paneName: nullptr);
47 al::setNerve(user: this, nerve: &NrvHostType.End);
48}
49
50void SimpleLayoutMenu::exeAppear() {
51 if (al::isActionEnd(layout: this, paneName: nullptr))
52 al::setNerve(user: this, nerve: &NrvHostType.Wait);
53}
54
55void SimpleLayoutMenu::exeWait() {
56 if (al::isFirstStep(user: this))
57 al::startAction(layout: this, actionName: "Wait", paneName: nullptr);
58 if (mWaitDuration >= 0 && al::isGreaterEqualStep(user: this, step: mWaitDuration))
59 al::setNerve(user: this, nerve: &NrvHostType.End);
60}
61
62void SimpleLayoutMenu::exeEnd() {
63 if (al::isActionEnd(layout: this, paneName: nullptr))
64 al::setNerve(user: this, nerve: &NrvHostType.EndWait);
65}
66
67void SimpleLayoutMenu::exeEndWait() {}
68
69bool SimpleLayoutMenu::isAppearOrWait() const {
70 return isWait() || al::isNerve(user: this, nerve: &NrvHostType.Appear);
71}
72
73bool SimpleLayoutMenu::isWait() const {
74 return al::isNerve(user: this, nerve: &NrvHostType.Wait);
75}
76
77bool SimpleLayoutMenu::isEndWait() const {
78 return al::isNerve(user: this, nerve: &NrvHostType.EndWait);
79}
80