SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
SubMeterLayout.cpp
1#include "Game/Screen/SubMeterLayout.hpp"
2#include "Game/Util.hpp"
3
4SubMeterLayout::SubMeterLayout(const char *pName, const char *pLayoutName) : LayoutActor(pName, true) {
5 MR::connectToSceneLayout(this);
6 initLayoutManager(pLayoutName, 1);
7 MR::createAndAddPaneCtrl(this, "Count", 1);
8}
9
11 MR::startPaneAnim(this, "Count", "Count", 0);
12 MR::setPaneAnimFrameAndStop(this, "Count", 0.0f, 0);
13 appear();
14 MR::hideLayout(this);
15 _20 = 0;
16 _26 = 0;
17}
18
19void SubMeterLayout::setLifeRatio(f32 ratio) {
20 f32 mult = 128.0f * ratio;
21 _22 = mult;
22 MR::setPaneAnimFrameAndStop(this, "Count", 0x80 - _22, 0);
23}
24
25void SubMeterLayout::requestDeactivate() {
26 MR::hideLayout(this);
27 _20 = 0;
28}
29
30void SubMeterLayout::requestAppear() {
31 MR::showLayout(this);
32 MR::startAnim(this, "Appear", nullptr);
33 _20 = 1;
34 control();
35}
36
37void SubMeterLayout::requestFrameIn() {
38 MR::showLayout(this);
39 MR::startAnim(this, "Appear", 0);
40 _20 = 1;
41 control();
42}
43
44void SubMeterLayout::requestFrameOut() {
45 MR::startAnim(this, "End", 0);
46 _20 = 4;
47}
48
49void SubMeterLayout::control() {
50 switch(_20) {
51 case 0:
52 break;
53 case 1:
54 if (MR::isAnimStopped(this, 0)) {
55 MR::startAnim(this, "Wait", 0);
56 _26 = 0;
57 _20 += 1;
58 }
59 break;
60 case 2:
61 if (_22 < 0x40) {
62 MR::startAnim(this, "Danger", 0);
63 _20 = 3;
64 }
65 break;
66 case 3:
67 if (_22 > 0x40) {
68 MR::startAnim(this, "Wait", 0);
69 MR::setAnimRate(this, 1.0f, 0);
70 _20 = 2;
71 }
72 else {
73 MR::setAnimRate(this, ((0x40 - _22) * 1.0f / 32.0f) + 1.0f, 0);
74 }
75 break;
76 case 4:
77 if (MR::isAnimStopped(this, 0)) {
78 MR::hideLayout(this);
79 _20 = 0;
80 }
81 break;
82 }
83
84 bool flag = true;
85
86 if (!MR::isPlayerInWaterMode()) {
87 if (!MR::isOnGroundPlayer()) {
88 flag = false;
89 }
90 }
91 else {
92 if (!MR::isPlayerOnWaterSurface()) {
93 flag = false;
94 }
95 }
96
97 if (flag) {
98 if (((_20 + 0xFE) & 0xFF) <= 1u && _22 == 0x80) {
99 if (++_26 == 60) {
100 MR::startAnim(this, "End", 0);
101 _20 = 5;
102 }
103 }
104 }
105 else if (_20 == 5) {
106 _20 = 1;
107 _26 = 0;
108 MR::startAnim(this, "Appear", 0);
109 }
110
111 if (!MR::isHiddenLayout(this)) {
112 TVec2f screenPos;
113 MR::calcScreenPosition(&screenPos, *MR::getPlayerPos());
114 screenPos.x += sScreenOffsetX;
115 screenPos.y += sScreenOffsetY;
116 setTrans(screenPos);
117 }
118}
119
120SubMeterLayout::~SubMeterLayout() {
121
122}
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.