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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
/**
* d_menu_fishing.cpp
* Menu - Fishing Journal
*/
#include "d/dolzel.h" // IWYU pragma: keep
#include "d/d_menu_fishing.h"
#include "JSystem/J2DGraph/J2DTextBox.h"
#include "JSystem/JKernel/JKRMemArchive.h"
#include "d/d_menu_dmap.h"
#include "d/d_meter2_info.h"
#include "d/d_meter_HIO.h"
#include "d/d_msg_string.h"
#include "m_Do/m_Do_controller_pad.h"
#include "m_Do/m_Do_graphic.h"
typedef void (dMenu_Fishing_c::*initFunc)();
initFunc map_init_process[] = {
&dMenu_Fishing_c::wait_init,
};
typedef void (dMenu_Fishing_c::*moveFunc)();
moveFunc map_move_process[] = {
&dMenu_Fishing_c::wait_move,
};
dMenu_Fishing_c::dMenu_Fishing_c(JKRExpHeap* i_heap, STControl* i_stick, CSTControl* i_cStick) {
mpHeap = i_heap;
mpArchive = 0;
mpMount = 0;
mpStick = i_stick;
mpCStick = i_cStick;
mStatus = READY_OPEN;
mProcess = 0;
mFishListScreenFrames = 0;
}
dMenu_Fishing_c::~dMenu_Fishing_c() {
delete mpString;
mpString = NULL;
delete mpBlackTex;
mpBlackTex = NULL;
delete mpScreen;
mpScreen = NULL;
delete mpParent;
mpParent = NULL;
for (int i = 0; i < MAX_FINDABLE_FISHES; i++) {
delete mpFishParent[i];
mpFishParent[i] = NULL;
for (int j = 0; j < MAX_FINDABLE_FISHES; j++) {
delete mpFishParts[j][i];
mpFishParts[j][i] = NULL;
}
}
for (int i = 0; i < 2; i++) {
delete mpFishInfoParent[i];
mpFishInfoParent[i] = NULL;
}
delete mpIconScreen;
mpIconScreen = NULL;
for (int i = 0; i < 2; i++) {
if (mpButtonAB[i]) {
delete mpButtonAB[i];
mpButtonAB[i] = NULL;
}
if (mpButtonText[i]) {
delete mpButtonText[i];
mpButtonText[i] = NULL;
}
}
if (mpMount) {
mpMount->getArchive()->unmount();
mpMount->destroy();
mpMount = NULL;
}
if (mpArchive) {
mpArchive->unmount();
mpArchive = NULL;
}
}
void dMenu_Fishing_c::_create() {
mpString = new dMsgString_c();
screenSetBase();
screenSetDoIcon();
setHIO(true);
init();
}
void dMenu_Fishing_c::_move() {
JKRHeap* heap = mDoExt_setCurrentHeap((JKRHeap*)mpHeap);
u8 old_process = mProcess;
(this->*map_move_process[mProcess])();
if (old_process != mProcess) {
(this->*map_init_process[mProcess])();
}
setHIO(false);
mDoExt_setCurrentHeap(heap);
}
void dMenu_Fishing_c::_draw() {
if (mpArchive) {
J2DGrafContext* grafPort = dComIfGp_getCurrentGrafPort();
mpBlackTex->setAlpha(0xff);
mpBlackTex->draw(0.0f, 0.0f, FB_WIDTH, FB_HEIGHT, 0, 0, 0);
mpScreen->draw(0.0f, 0.0f, grafPort);
mpIconScreen->draw(0.0f, 0.0f, grafPort);
}
}
bool dMenu_Fishing_c::isSync() {
if (mpMount != NULL && !mpMount->sync()) {
return false;
}
return true;
}
void dMenu_Fishing_c::init() {
#if VERSION == VERSION_GCN_PAL
BOOL isEnglish = FALSE;
if (dComIfGs_getPalLanguage() == dSv_player_config_c::LANGAUGE_ENGLISH) {
isEnglish = TRUE;
}
#endif
for (int i = 0; i < MAX_FINDABLE_FISHES; i++) {
if (dComIfGs_getFishNum(i) != 0) {
// Fish has been caught once, display it along with it's params
#if VERSION == VERSION_GCN_PAL
if (isEnglish) {
setFishParam(i, dComIfGs_getFishNum(i), dComIfGs_getFishSize(i) / 2.54f);
} else {
setFishParam(i, dComIfGs_getFishNum(i), dComIfGs_getFishSize(i));
}
#else
setFishParam(i, dComIfGs_getFishNum(i), dComIfGs_getFishSize(i));
#endif
mpFishParent[i]->show();
} else {
// Fish hasn't been caught yet, don't display it and also hide params
mpFishParent[i]->hide();
}
}
(this->*map_init_process[mProcess])();
}
int dMenu_Fishing_c::_open() {
if (mpMount == NULL) {
mpMount = mDoDvdThd_mountArchive_c::create("/res/Layout/fishres.arc", 0, NULL);
}
if (mpArchive == NULL) {
if (mpMount->sync()) {
if (mpArchive == NULL) {
mpArchive = (JKRArchive*)mpMount->getArchive();
delete mpMount;
mpMount = NULL;
_create();
}
} else {
return 0;
}
}
s16 openFrames = g_drawHIO.mFishListScreen.mOpenFrames;
s16 closeFrames = g_drawHIO.mFishListScreen.mCloseFrames;
mFishListScreenFrames = g_drawHIO.mFishListScreen.mOpenFrames;
if (mFishListScreenFrames >= openFrames) {
mFishListScreenFrames = closeFrames;
mStatus = READY_MOVE;
mpParent->scale(1.0f, 1.0f);
mpParent->setAlphaRate(1.0f);
return 1;
} else {
f32 div = mFishListScreenFrames / (f32)openFrames;
mpParent->scale(div, div);
mpParent->setAlphaRate(div);
return 0;
}
}
int dMenu_Fishing_c::_close() {
s16 closeFrames = g_drawHIO.mFishListScreen.mCloseFrames;
mFishListScreenFrames = 0;
if (mFishListScreenFrames <= 0) {
mFishListScreenFrames = 0;
mStatus = CLOSED;
mpParent->scale(0.0f, 0.0f);
mpParent->setAlphaRate(0.0f);
return 1;
} else {
f32 div = mFishListScreenFrames / (f32)closeFrames;
mpParent->scale(div, div);
mpParent->setAlphaRate(div);
return 0;
}
}
// While the fishing menu is open,
void dMenu_Fishing_c::wait_init() {
setAButtonString(0);
setBButtonString(0x3F9); // "Back"
}
void dMenu_Fishing_c::wait_move() {
if (mDoGph_gInf_c::getFader()->getStatus() == 1 && mDoCPd_c::getTrigB(PAD_1)) {
mStatus = READY_CLOSE;
}
}
void dMenu_Fishing_c::screenSetBase() {
static const u64 fish_n[6] = {
'fish_n_6', 'fish_n_5', 'fish_n_3', 'fish_n_1', 'fish_n_2', 'fish_n_4',
};
static const u64 fish_p0[6] = {
'fi_pa_6n', 'fi_pa_5n', 'fi_pa_3n', 'fi_pa_1n', 'fi_pa_2n', 'fi_pa_4n',
};
static const u64 fish_p1[6] = {
'fi_na_6n', 'fi_na_5n', 'fi_na_3n', 'fi_na_1n', 'fi_na_2n', 'fi_na_4n',
};
static const u64 fish_p2[6] = {'fi_li_6n', 'fi_li_5n', 'fi_li_3n',
'fi_li_1n', 'fi_li_2n', 'fi_li_4n'};
static const u64 fish_p3[6] = {
'b_box_6n', 'b_box_5n', 'b_box_3n', 'b_box_1n', 'b_box_2n', 'b_box_4n',
};
static const u64 fish_p4[6] = {
'r_box_6n', 'r_box_5n', 'r_box_3n', 'r_box_1n', 'r_box_2n', 'r_box_4n',
};
static const u64 fish_p5[6] = {
'info_6_n', 'info_5_n', 'info_3_n', 'info_1_n', 'info_2_n', 'info_4_n',
};
static const u64 size_1[6] = {
'size_t_6', 'size_t_5', 'size_t_3', 'size_t_1', 'size_t_2', 'size_t_4',
};
static const u64 size_unit_1[6] = {
'cm_t_6', 'cm_t_5', 'cm_t_3', 'cm_t_1', 'cm_t_2', 'cm_t_4',
};
static const u64 count_1[6] = {
'count_t6', 'count_t5', 'count_t3', 'count_t1', 'count_t2', 'count_t4',
};
static const u64 count_unit_1[6] = {
'cou_t_6', 'cou_t_5', 'cou_t_3', 'cou_t_1', 'cou_t_2', 'cou_t_4',
};
static const u64 name_0[6] = {
'name_6', 'name_5', 'name_3', 'name_1', 'name_2', 'name_4',
};
static const u64 fname_0[6] = {
'f_name_6', 'f_name_5', 'f_name_3', 'f_name_1', 'f_name_2', 'f_name_4',
};
static const u32 name_id[6] = {
0x59E, 0x59D, 0x59B, 0x599, 0x59A, 0x59C,
};
ResTIMG* TIMG = (ResTIMG*)dComIfGp_getMain2DArchive()->getResource('TIMG', "tt_block8x8.bti");
mpBlackTex = new J2DPicture(TIMG);
mpBlackTex->setBlackWhite(JUtility::TColor(0, 0, 0, 0), JUtility::TColor(0, 0, 0, 0xFF));
mpScreen = new J2DScreen();
mpScreen->setPriority("zelda_fish_window.blo", 0x20000, mpArchive);
dPaneClass_showNullPane(mpScreen);
mpParent = new CPaneMgr(mpScreen, 'n_all', 2, NULL);
mpParent->setAlphaRate(0.0f);
for (int i = 0; i < MAX_FINDABLE_FISHES; i++) {
mpFishParent[i] = new CPaneMgr(mpScreen, fish_n[i], 0, NULL);
mpFishParts[0][i] = new CPaneMgr(mpScreen, fish_p0[i], 0, NULL);
mpFishParts[1][i] = new CPaneMgr(mpScreen, fish_p1[i], 0, NULL);
mpFishParts[2][i] = new CPaneMgr(mpScreen, fish_p2[i], 0, NULL);
mpFishParts[3][i] = new CPaneMgr(mpScreen, fish_p3[i], 0, NULL);
mpFishParts[4][i] = new CPaneMgr(mpScreen, fish_p4[i], 0, NULL);
mpFishParts[5][i] = new CPaneMgr(mpScreen, fish_p5[i], 0, NULL);
}
mpFishInfoParent[0] = new CPaneMgr(mpScreen, 'info_blu', 0, NULL);
mpFishInfoParent[1] = new CPaneMgr(mpScreen, 'info_red', 0, NULL);
#if (VERSION == VERSION_GCN_JPN) || (VERSION == VERSION_WII_JPN)
J2DTextBox* textBox = (J2DTextBox*)mpScreen->search('t_t00');
mpScreen->search('f_t00')->hide();
#else
J2DTextBox* textBox = (J2DTextBox*)mpScreen->search('f_t00');
mpScreen->search('t_t00')->hide();
#endif
textBox->setFont(mDoExt_getSubFont());
textBox->setString(0x200, "");
mpString->getString(0x5a1, textBox, NULL, NULL, NULL, 0);
for (int i = 0; i < MAX_FINDABLE_FISHES; i++) {
field_0x10c[1][i] = (J2DTextBox*)mpScreen->search(size_1[i]);
field_0x10c[1][i]->setFont(mDoExt_getSubFont());
field_0x10c[1][i]->setString(0x20, "");
field_0x16c[1][i] = (J2DTextBox*)mpScreen->search(size_unit_1[i]);
field_0x16c[1][i]->setFont(mDoExt_getSubFont());
field_0x16c[1][i]->setString(0x20, "");
field_0x13c[1][i] = (J2DTextBox*)mpScreen->search(count_1[i]);
field_0x13c[1][i]->setFont(mDoExt_getSubFont());
field_0x13c[1][i]->setString(0x20, "");
field_0x19c[1][i] = (J2DTextBox*)mpScreen->search(count_unit_1[i]);
field_0x19c[1][i]->setFont(mDoExt_getSubFont());
field_0x19c[1][i]->setString(0x20, "");
mpFishNameString[i] = (J2DTextBox*)mpScreen->search(name_0[i]);
mpScreen->search(fname_0[i])->hide();
mpFishNameString[i]->setFont(mDoExt_getSubFont());
mpFishNameString[i]->setString(0x20, "");
dMeter2Info_getStringKanji(name_id[i], mpFishNameString[i]->getStringPtr(), NULL);
}
mpInfoLargestString = (J2DTextBox*)mpScreen->search('inf_size');
mpInfoNumCaughtString = (J2DTextBox*)mpScreen->search('inf_cou');
mpInfoLargestString->setFont(mDoExt_getMesgFont());
mpInfoNumCaughtString->setFont(mDoExt_getMesgFont());
mpInfoLargestString->setString(0x20, "");
dMeter2Info_getStringKanji(0x59f, mpInfoLargestString->getStringPtr(), NULL); // "Largest"
mpInfoNumCaughtString->setString(0x20, "");
dMeter2Info_getStringKanji(0x5a0, mpInfoNumCaughtString->getStringPtr(), NULL); // "No. Caught"
}
void dMenu_Fishing_c::screenSetDoIcon() {
static const u64 text_a_tag[5] = {'atext1_1', 'atext1_2', 'atext1_3', 'atext1_4', 'atext1_5'};
static const u64 text_b_tag[5] = {'btext1_1', 'btext1_2', 'btext1_3', 'btext1_4', 'btext1_5'};
mpIconScreen = new J2DScreen();
mpIconScreen->setPriority("zelda_collect_soubi_do_icon_parts.blo", 0x20000, mpArchive);
for (int i = 0; i < 2; i++) {
mpButtonAB[i] = NULL;
mpButtonText[i] = NULL;
}
dPaneClass_showNullPane(mpIconScreen);
for (int i = 0; i < 5; i++) {
mpAButtonString[i] = (J2DTextBox*)mpIconScreen->search(text_a_tag[i]);
mpBButtonString[i] = (J2DTextBox*)mpIconScreen->search(text_b_tag[i]);
mpAButtonString[i]->setFont(mDoExt_getMesgFont());
mpBButtonString[i]->setFont(mDoExt_getMesgFont());
mpAButtonString[i]->setString(0x20, "");
mpBButtonString[i]->setString(0x20, "");
}
}
void dMenu_Fishing_c::setAButtonString(u16 i_stringID) {
if (i_stringID == 0) {
for (int i = 0; i < 5; i++) {
strcpy(mpAButtonString[i]->getStringPtr(), "");
}
} else {
for (int i = 0; i < 5; i++) {
dMeter2Info_getStringKanji(i_stringID, mpAButtonString[i]->getStringPtr(), NULL);
}
}
}
void dMenu_Fishing_c::setBButtonString(u16 i_stringID) {
if (i_stringID == 0) {
for (int i = 0; i < 5; i++) {
strcpy(mpBButtonString[i]->getStringPtr(), "");
}
} else {
for (int i = 0; i < 5; i++) {
dMeter2Info_getStringKanji(i_stringID, mpBButtonString[i]->getStringPtr(), NULL);
}
}
}
u8 dMenu_Fishing_c::getFigure(int param_0) {
if (param_0 < 0) {
param_0 *= -1;
}
if (1000 <= param_0) {
param_0 = 999;
}
if (100 <= param_0) {
return 3;
}
if (param_0 >= 10) {
return 2;
}
return 1;
}
void dMenu_Fishing_c::setFishParam(int i_fishIdx, u16 i_fishCount, u8 i_fishSize) {
u8 fishCountFigure = getFigure(i_fishCount);
u8 fishSizeFigure = getFigure(i_fishSize);
char strBuff1[32];
char strBuff2[32];
for (int i = 1; i < 2; i++) {
// part one, i_fishSize
dComIfGp_setMessageCountNumber(i_fishSize);
mpString->getString(0x597, field_0x10c[i][i_fishIdx], NULL, NULL, NULL, 0); // "inches"
char* stringPtr = field_0x10c[i][i_fishIdx]->getStringPtr();
strcpy(strBuff1, stringPtr);
int j;
for (j = 0; strBuff1[j + fishSizeFigure] != 0; j++) {
strBuff2[j] = strBuff1[j + fishSizeFigure];
}
strBuff2[j] = 0;
strBuff1[fishSizeFigure] = 0;
strcpy(field_0x10c[i][i_fishIdx]->getStringPtr(), strBuff1);
strcpy(field_0x16c[i][i_fishIdx]->getStringPtr(), strBuff2);
// part two, i_fishCount
dComIfGp_setMessageCountNumber(i_fishCount);
mpString->getString(0x598, field_0x13c[i][i_fishIdx], NULL, NULL, NULL, 0); // "fish"
stringPtr = field_0x13c[i][i_fishIdx]->getStringPtr();
strcpy(strBuff1, stringPtr);
int k;
for (k = 0; strBuff1[k + fishCountFigure] != 0; k++) {
strBuff2[k] = strBuff1[k + fishCountFigure];
}
strBuff2[k] = 0;
strBuff1[fishCountFigure] = 0;
strcpy(field_0x13c[i][i_fishIdx]->getStringPtr(), strBuff1);
strcpy(field_0x19c[i][i_fishIdx]->getStringPtr(), strBuff2);
}
}
void dMenu_Fishing_c::setHIO(bool i_useHIO) {
if (i_useHIO || g_drawHIO.mFishListScreen.mDebug) {
for (int i = 0; i < MAX_FINDABLE_FISHES; i++) {
mpFishParent[i]->paneTrans(g_drawHIO.mFishListScreen.mFishInfoPosX[i],
g_drawHIO.mFishListScreen.mFishInfoPosY[i]);
mpFishParent[i]->scale(g_drawHIO.mFishListScreen.mFishInfoScale[i],
g_drawHIO.mFishListScreen.mFishInfoScale[i]);
mpFishParts[0][i]->paneTrans(g_drawHIO.mFishListScreen.mFishIconPosX[i],
g_drawHIO.mFishListScreen.mFishIconPosY[i]);
mpFishParts[0][i]->scale(g_drawHIO.mFishListScreen.mFishIconScale[i],
g_drawHIO.mFishListScreen.mFishIconScale[i]);
mpFishParts[1][i]->paneTrans(g_drawHIO.mFishListScreen.mFishNamePosX[i],
g_drawHIO.mFishListScreen.mFishNamePosY[i]);
mpFishParts[1][i]->scale(g_drawHIO.mFishListScreen.mFishNameScale[i],
g_drawHIO.mFishListScreen.mFishNameScale[i]);
mpFishParts[2][i]->paneTrans(g_drawHIO.mFishListScreen.mFishLinePosX[i],
g_drawHIO.mFishListScreen.mFishLinePosY[i]);
mpFishParts[2][i]->scale(g_drawHIO.mFishListScreen.mFishLineScale[i],
g_drawHIO.mFishListScreen.mFishLineScale[i]);
mpFishParts[3][i]->paneTrans(g_drawHIO.mFishListScreen.mFishSizePosX[i],
g_drawHIO.mFishListScreen.mFishSizePosY[i]);
mpFishParts[3][i]->scale(g_drawHIO.mFishListScreen.mFishSizeScale[i],
g_drawHIO.mFishListScreen.mFishSizeScale[i]);
mpFishParts[4][i]->paneTrans(g_drawHIO.mFishListScreen.mFishCountPosX[i],
g_drawHIO.mFishListScreen.mFishCountPosY[i]);
mpFishParts[4][i]->scale(g_drawHIO.mFishListScreen.mFishCountScale[i],
g_drawHIO.mFishListScreen.mFishCountScale[i]);
mpFishParts[5][i]->paneTrans(g_drawHIO.mFishListScreen.mFishCountSizePosX[i],
g_drawHIO.mFishListScreen.mFishCountSizePosY[i]);
mpFishParts[5][i]->scale(g_drawHIO.mFishListScreen.mFishCountSizeScale[i],
g_drawHIO.mFishListScreen.mFishCountSizeScale[i]);
}
for (int i = 0; i < 2; i++) {
mpFishInfoParent[i]->paneTrans(g_drawHIO.mFishListScreen.mPosX[i],
g_drawHIO.mFishListScreen.mPosY[i]);
mpFishInfoParent[i]->scale(g_drawHIO.mFishListScreen.mScale[i],
g_drawHIO.mFishListScreen.mScale[i]);
}
}
if (g_drawHIO.mCollectScreen.mButtonDebugON || i_useHIO) {
if (mpButtonAB[A_BUTTON] != NULL) {
mpButtonAB[A_BUTTON]->paneTrans(g_drawHIO.mCollectScreen.mButtonAPosX,
g_drawHIO.mCollectScreen.mButtonAPosY);
mpButtonAB[A_BUTTON]->scale(g_drawHIO.mCollectScreen.mButtonAScale,
g_drawHIO.mCollectScreen.mButtonAScale);
}
if (mpButtonAB[B_BUTTON] != NULL) {
mpButtonAB[B_BUTTON]->paneTrans(g_drawHIO.mCollectScreen.mButtonBPosX,
g_drawHIO.mCollectScreen.mButtonBPosY);
mpButtonAB[B_BUTTON]->scale(g_drawHIO.mCollectScreen.mButtonBScale,
g_drawHIO.mCollectScreen.mButtonBScale);
}
if (mpButtonText[A_BUTTON] != NULL) {
mpButtonText[A_BUTTON]->paneTrans(g_drawHIO.mCollectScreen.mButtonATextPosX,
g_drawHIO.mCollectScreen.mButtonATextPosY);
mpButtonText[A_BUTTON]->scale(g_drawHIO.mCollectScreen.mButtonATextScale,
g_drawHIO.mCollectScreen.mButtonATextScale);
}
if (mpButtonText[B_BUTTON] != NULL) {
mpButtonText[B_BUTTON]->paneTrans(g_drawHIO.mCollectScreen.mButtonBTextPosX,
g_drawHIO.mCollectScreen.mButtonBTextPosY);
mpButtonText[B_BUTTON]->scale(g_drawHIO.mCollectScreen.mButtonBTextScale,
g_drawHIO.mCollectScreen.mButtonBTextScale);
}
}
}
|