1#include "Library/Play/Layout/SimplePopupMessageLayout.h"
2
3#include "Library/Layout/LayoutActionFunction.h"
4#include "Library/Layout/LayoutActor.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#include "Library/Screen/ScreenFunction.h"
10
11namespace {
12using namespace al;
13NERVE_HOST_TYPE_IMPL(SimplePopupMessageLayout, Appear);
14NERVE_HOST_TYPE_IMPL(SimplePopupMessageLayout, End);
15NERVE_HOST_TYPE_IMPL(SimplePopupMessageLayout, Wait);
16
17NERVES_MAKE_NOSTRUCT(HostType, End);
18NERVES_MAKE_STRUCT(HostType, Appear, Wait);
19} // namespace
20
21namespace al {
22
23SimplePopupMessageLayout::SimplePopupMessageLayout(const char* name, const char* layoutName,
24 const LayoutInitInfo& info,
25 const char* archiveName, bool localize)
26 : LayoutActor(name) {
27 if (localize)
28 initLayoutActorLocalized(this, info, layoutName, archiveName);
29 else
30 initLayoutActor(this, info, layoutName, archiveName);
31 initNerve(&NrvHostType.Appear, 0);
32}
33
34void SimplePopupMessageLayout::appear() {
35 startAction(layout: this, actionName: "Appear", paneName: nullptr);
36 LayoutActor::appear();
37 setNerve(user: this, nerve: &NrvHostType.Appear);
38}
39
40void SimplePopupMessageLayout::end() {
41 if (!isNerve(user: this, nerve: &End))
42 setNerve(user: this, nerve: &End);
43}
44
45void SimplePopupMessageLayout::startWait() {
46 startAction(layout: this, actionName: "Wait", paneName: nullptr);
47 LayoutActor::appear();
48 setNerve(user: this, nerve: &NrvHostType.Wait);
49}
50
51void SimplePopupMessageLayout::exeAppear() {
52 refreshPos();
53
54 if (isActionEnd(layout: this, paneName: nullptr))
55 setNerve(user: this, nerve: &NrvHostType.Wait);
56}
57
58void SimplePopupMessageLayout::refreshPos() {
59 sead::Vector2f layoutPos = sead::Vector2f::zero;
60 calcLayoutPosFromWorldPos(output: &layoutPos, this, mWorldPos);
61 setLocalTrans(this, layoutPos);
62}
63
64void SimplePopupMessageLayout::exeWait() {
65 refreshPos();
66
67 if (isFirstStep(user: this))
68 startAction(layout: this, actionName: "Wait", paneName: nullptr);
69 if (mLifetime >= 0 && isGreaterEqualStep(user: this, step: mLifetime))
70 setNerve(user: this, nerve: &End);
71}
72
73void SimplePopupMessageLayout::exeEnd() {
74 refreshPos();
75
76 if (isFirstStep(user: this))
77 startAction(layout: this, actionName: "End", paneName: nullptr);
78 if (isActionEnd(layout: this, paneName: nullptr))
79 kill();
80}
81
82bool SimplePopupMessageLayout::isWait() const {
83 return isNerve(user: this, nerve: &NrvHostType.Wait);
84}
85
86bool SimplePopupMessageLayout::isAppearOrWait() const {
87 return isWait() || isNerve(user: this, nerve: &NrvHostType.Appear);
88}
89
90} // namespace al
91