1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
#include "koopatlas/hud.h"
dWMHud_c *dWMHud_c::instance = 0;
dWMHud_c *dWMHud_c::build() {
void *buffer = AllocFromGameHeap1(sizeof(dWMHud_c));
dWMHud_c *c = new(buffer) dWMHud_c;
instance = c;
return c;
}
dWMHud_c::dWMHud_c() {
layoutLoaded = false;
}
// TODO: Need to define these in a better way, somehow
#define ANIM_BUTTON_1 0
#define ANIM_BUTTON_2 1
#define ANIM_BOTTOM_SHOW 2
#define ANIM_BOTTOM_HIDE 3
#define ANIM_TOP_SHOW 4
#define ANIM_TOP_HIDE 5
int dWMHud_c::onCreate() {
if (!layoutLoaded) {
bool gotFile = layout.loadArc("maphud.arc", false);
if (!gotFile)
return false;
//static const char *brlanNames[3] = {"maphud_hitbutton.brlan", "maphud_in.brlan", "maphud_out.brlan"};
static const char *brlanNames[5] = {"maphud_hitbutton.brlan", "bottom_in.brlan", "bottom_out.brlan", "top_in.brlan", "top_out.brlan"};
static const char *groupNames[6] = {"B01_Button", "B02_Button", "A00_Window", "A00_Window", "A01_Window", "A01_Window"};
bool output = layout.build("maphud.brlyt");
if (!IsWideScreen()) {
layout.clippingEnabled = true;
layout.clipX = 0;
layout.clipY = 52;
layout.clipWidth = 640;
layout.clipHeight = 352;
layout.layout.rootPane->scale.x = 0.7711f;
layout.layout.rootPane->scale.y = 0.7711f;
}
layout.loadAnimations(brlanNames, 5);
layout.loadGroups(groupNames, (int[6]){0, 0, 1, 2, 3, 4}, 6);
layout.disableAllAnimations();
layout.enableNonLoopAnim(ANIM_BOTTOM_SHOW);
showPointBar();
if (dScKoopatlas_c::instance->pathManager.mustComplainToMapCreator)
dWMHud_c::instance->setText("Please Fix Your Missing Entrance. Thanks");
layoutLoaded = true;
}
return true;
}
int dWMHud_c::onDelete() {
return layout.free();
}
int dWMHud_c::onExecute() {
layout.execAnimations();
layout.update();
return true;
}
int dWMHud_c::onDraw() {
layout.scheduleForDrawing();
return true;
}
void dWMHud_c::updateText() {
setPointName();
}
void dWMHud_c::setText(const char *str, int length) {
if (str == 0) {
setText("--NULL STRING--");
return;
}
if (length == -1) {
length = strlen(str);
}
wchar_t newString[128];
int i;
for (i = 0; i < length && i < 128; i++) {
newString[i] = str[i];
}
newString[i] = 0;
setText(newString, i);
}
void dWMHud_c::setText(const wchar_t *str, int length) {
if (str == 0) {
setText("--NULL STRING--");
return;
}
if (length == -1) {
length = wcslen(str);
}
nw4r::lyt::TextBox *box = layout.findTextBoxByName("T_levelname_01");
nw4r::ut::TextWriter tw;
tw.font = box->font;
tw.SetFontSize(box->fontSizeX, box->fontSizeY);
tw.somethingRelatedToLineHeight = box->lineSpace;
tw.charSpace = box->charSpace;
if (box->tagProc != 0)
tw.tagProcessorMaybe = box->tagProc;
float width = tw.CalcStringWidth(str, length);
SpammyReport("Text width: %f\n", width);
layout.findWindowByName("W_levelname")->size.x = width + 22;
layout.findPictureByName("P_topleftboxbg")->size.x = width;
layout.findPictureByName("P_topthinboxbg")->size.x = 597 - width;
box->SetString(str);
}
void dWMHud_c::setPointName() {
// figure this out...
dKPNode_s *node = dScKoopatlas_c::instance->pathManager.currentNode;
if (node->type == dKPNode_s::LEVEL) {
dLevelInfo_c *li = &dScKoopatlas_c::instance->levelInfo;
dLevelInfo_c::entry_s *entry = li->search(node->levelNumber[0] - 1, node->levelNumber[1] - 1);
setText(li->getNameForLevel(entry));
} else {
setText("");
}
}
void dWMHud_c::showPointBar() {
dKPNode_s *node = dScKoopatlas_c::instance->pathManager.currentNode;
if (node->type == dKPNode_s::LEVEL) {
isPointBarShown = true;
updateText();
layout.enableNonLoopAnim(ANIM_TOP_SHOW);
}
}
void dWMHud_c::hidePointBar() {
if (isPointBarShown) {
isPointBarShown = false;
layout.enableNonLoopAnim(ANIM_TOP_HIDE);
}
}
|