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
|
#include <game.h>
#include "levelinfo.h"
#include <newer.h>
dDvdLoader_c s_levelInfoLoader;
dLevelInfo_c s_levelInfo;
bool s_levelInfoLoaded = false;
// TODO: refactor this a tiny bit
bool LoadLevelInfo() {
if (s_levelInfoLoaded)
return true;
void *data = s_levelInfoLoader.load("/NewerRes/LevelInfo.bin");
if (data) {
s_levelInfo.load(data);
s_levelInfoLoaded = true;
return true;
}
return false;
}
class PregameLytHandler {
public:
m2d::EmbedLayout_c layout;
nw4r::lyt::Pane *rootPane;
nw4r::lyt::TextBox
*T_minus_00, *T_world_00, *T_worldNum_00,
*T_pictureFont_00, *T_corseNum_00,
*T_remainder_00, *T_remainder_01, *T_remainder_02, *T_remainder_03,
*T_remainder_10, *T_remainder_11, *T_remainder_12, *T_remainder_13,
*T_x_00, *T_x_01, *T_x_02, *T_x_03, *T_x_10, *T_x_11, *T_x_12, *T_x_13,
*T_x_00_o, *T_x_10_o,
*T_otasukePlay_00, *T_otasukePlay_01,
*T_recommend_00, *T_remainder_00_o, *T_remainder_10_o;
nw4r::lyt::Picture
*P_Wx_00[9], *P_coin_00, *P_free_00,
*P_batB_0x[4], *P_bat_00,
*P_batB_1x[4], *P_bat_01,
*P_batB_2x[4], *P_bat_02,
*P_batB_3x[4], *P_bat_03,
*P_luijiIcon_00_o, *P_luijiIcon_10_o, *P_coinStage_00;
nw4r::lyt::Pane
*N_mario_00, *N_luiji_00, *N_kinoB_01, *N_kinoY_00,
*N_zankiPos_x[4], *N_zanki_00,
*Null_battPosxP[4], *N_batt_x[4],
*N_batt, *N_otasukePlay_00;
u8 layoutLoaded, somethingHasBeenDone, isVisible, hasShownLuigiThing_orSomething;
u32 currentStateID;
u32 _2E8;
u32 countdownToEndabilityCopy, activePlayerCountMultBy4_maybe;
u32 batteryLevels[4];
u32 pgCountdown;
void hijack_loadLevelNumber(); // replaces 80B6BDD0
};
// Notes:
// Deleted; P_coinStage_00, T_recommend_00, T_worldNum_00,
// T_-_00, T_pictureFont_00, T_corseNum_00, T_world_00
// P_Wx_00, P_coin_00, P_free_00
extern char CurrentLevel;
extern char CurrentWorld;
#include "fileload.h"
void PregameLytHandler::hijack_loadLevelNumber() {
nw4r::lyt::TextBox
*LevelNumShadow, *LevelNum,
*LevelNameShadow, *LevelName;
LevelNumShadow = layout.findTextBoxByName("LevelNumShadow");
LevelNum = layout.findTextBoxByName("LevelNum");
LevelNameShadow = layout.findTextBoxByName("LevelNameShadow");
LevelName = layout.findTextBoxByName("LevelName");
// work out the thing now
dLevelInfo_c::entry_s *level = s_levelInfo.searchBySlot(CurrentWorld, CurrentLevel);
if (level) {
wchar_t convLevelName[160];
const char *srcLevelName = s_levelInfo.getNameForLevel(level);
int i = 0;
while (i < 159 && srcLevelName[i]) {
convLevelName[i] = srcLevelName[i];
i++;
}
convLevelName[i] = 0;
LevelNameShadow->SetString(convLevelName);
LevelName->SetString(convLevelName);
wchar_t levelNumber[32];
wcscpy(levelNumber, L"World ");
getNewerLevelNumberString(level->displayWorld, level->displayLevel, &levelNumber[6]);
LevelNumShadow->SetString(levelNumber);
LevelNum->SetString(levelNumber);
} else {
LevelNameShadow->SetString(L"Not found in LevelInfo!");
LevelName->SetString(L"Not found in LevelInfo!");
}
nw4r::lyt::Picture *LevelSample;
LevelSample = layout.findPictureByName("LevelSample");
// this is not the greatest way to read a file but I suppose it works in a pinch
char tplName[64];
sprintf(tplName, "/LevelSamples/%02d-%02d.tpl", CurrentWorld+1, CurrentLevel+1);
static File tpl;
if (tpl.open(tplName)) {
LevelSample->material->texMaps[0].ReplaceImage((TPLPalette*)tpl.ptr(), 0);
}
}
|