summaryrefslogtreecommitdiff
path: root/src/koopatlas
diff options
context:
space:
mode:
Diffstat (limited to 'src/koopatlas')
-rw-r--r--src/koopatlas/hud.cpp50
-rw-r--r--src/koopatlas/map.cpp90
-rw-r--r--src/koopatlas/mapdata.cpp32
-rw-r--r--src/koopatlas/mapdata.h18
4 files changed, 123 insertions, 67 deletions
diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp
index 286bbf5..3565c10 100644
--- a/src/koopatlas/hud.cpp
+++ b/src/koopatlas/hud.cpp
@@ -2,6 +2,27 @@
void CharToWChar(const char *input, wchar_t *output, int length) { for (int i = 0; i < length; i++) output[i] = input[i]; }
+int getStarCoinCount() {
+
+ SaveBlock *save = GetSaveFile()->GetBlock(-1);
+ int coinsSpent = save->ambush_countdown[0];
+ int coinsEarned = 0;
+
+ for (int w = 0; w < 10; w++) {
+ for (int l = 0; l < 10; l++) {
+ u32 conds = save->GetLevelCondition(w, l);
+
+ if (conds & COND_COIN1) { coinsEarned++; }
+ if (conds & COND_COIN2) { coinsEarned++; }
+ if (conds & COND_COIN3) { coinsEarned++; }
+ }
+ }
+
+ int coinsLeft = coinsEarned - coinsSpent;
+ return coinsLeft;
+}
+
+
dWMHud_c *dWMHud_c::instance = 0;
dWMHud_c *dWMHud_c::build() {
@@ -14,8 +35,6 @@ dWMHud_c *dWMHud_c::build() {
return c;
}
-
-
dWMHud_c::dWMHud_c() {
layoutLoaded = false;
}
@@ -125,6 +144,18 @@ void dWMHud_c::updateLives() {
pic->alpha = 0;
}
}
+
+ nw4r::lyt::TextBox *coinbox = layout.findTextBoxByName("T_coin_count_01");
+
+ char stars [4];
+ int starCoinCount = getStarCoinCount();
+ sprintf(stars, "%03d", starCoinCount);
+ const char *scoins = stars;
+ wchar_t wcoins;
+
+ CharToWChar(scoins, &wcoins, 4);
+
+ coinbox->SetString(&wcoins);
}
void dWMHud_c::setLevelText(const char *str, int length) {
@@ -269,6 +300,16 @@ void dWMHud_c::checkPointStatus() {
pic->alpha = 0;
}
+ u8 deaths = save->death_counts[world-1][level-1];
+ nw4r::lyt::TextBox *deathbox = layout.findTextBoxByName("T_death_01");
+
+ char die [4];
+ sprintf(die, "%03d", deaths);
+ const char *dies = die;
+ wchar_t wdie;
+ CharToWChar(dies, &wdie, 4);
+ deathbox->SetString(&wdie);
+
} else {
nw4r::lyt::Pane *pic;
@@ -279,6 +320,11 @@ void dWMHud_c::checkPointStatus() {
pic = layout.findPictureByName(picNames[i]);
pic->alpha = 0;
}
+
+ nw4r::lyt::TextBox *deathbox = layout.findTextBoxByName("T_death_01");
+ wchar_t noDie;
+ CharToWChar("---", &noDie, 4);
+ deathbox->SetString(&noDie);
}
}
diff --git a/src/koopatlas/map.cpp b/src/koopatlas/map.cpp
index bca294c..9a04e65 100644
--- a/src/koopatlas/map.cpp
+++ b/src/koopatlas/map.cpp
@@ -300,19 +300,20 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) {
for (int j = 0; j < doodad->animationCount; j++) {
dKPDoodad_s::animation_s *anim = &doodad->animations[j];
- if (anim->delayOffset == 0) {
+ // FORWARDS COMPATIBILITY: (has a ***)
+ // *** if (anim->delayOffset == 0) {
u32 baseTick = anim->baseTick;
if (baseTick == 0) {
anim->baseTick = baseTick = GlobalTickCount;
}
u32 elapsed = GlobalTickCount - baseTick;
- u32 elapsedAdjusted = elapsed;
+ // *** u32 elapsedAdjusted = elapsed;
if (anim->isReversed)
elapsed = anim->frameCount - 1 - elapsed;
if (elapsed >= anim->frameCount) {
- if (elapsed >= (anim->frameCount + anim->delay)) {
+ // *** if (elapsed >= (anim->frameCount + anim->delay)) {
// we've reached the end
switch (anim->loop) {
@@ -334,12 +335,13 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) {
anim->baseTick = GlobalTickCount;
break;
}
- }
- elapsedAdjusted = anim->frameCount;
+ // *** }
+ // *** elapsedAdjusted = anim->frameCount;
}
// now calculate the thing
- float progress = elapsedAdjusted / (float)anim->frameCount;
+ // *** float progress = elapsedAdjusted / (float)anim->frameCount;
+ float progress = elapsed / (float)anim->frameCount;
float value;
switch (anim->curve) {
@@ -383,10 +385,10 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) {
// TODO
break;
}
- }
- else {
- anim->delayOffset -= 1;
- }
+ // *** }
+ // *** else {
+ // *** anim->delayOffset -= 1;
+ // *** }
}
}
@@ -421,50 +423,50 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) {
void dWMMap_c::renderer_c::renderPathLayer(dKPLayer_s *layer) {
return;
- for (int i = 0; i < layer->nodeCount; i++) {
- dKPNode_s *node = layer->nodes[i];
+ // for (int i = 0; i < layer->nodeCount; i++) {
+ // dKPNode_s *node = layer->nodes[i];
- int world = node->levelNumber[0];
- int level = node->levelNumber[1];
+ // int world = node->levelNumber[0];
+ // int level = node->levelNumber[1];
- SaveBlock *save = GetSaveFile()->GetBlock(-1);
- u32 conds = save->GetLevelCondition(world-1, level-1);
+ // SaveBlock *save = GetSaveFile()->GetBlock(-1);
+ // u32 conds = save->GetLevelCondition(world-1, level-1);
- bool isUnlocked = true;
- bool exitComplete = false;
- bool secretComplete = false;
+ // bool isUnlocked = true;
+ // bool exitComplete = false;
+ // bool secretComplete = false;
- if (conds & 0x10)
- exitComplete = true;
- if (conds & 0x20)
- secretComplete = true;
+ // if (conds & 0x10)
+ // exitComplete = true;
+ // if (conds & 0x20)
+ // secretComplete = true;
- // Is it unlocked?
- if (!isUnlocked)
- node->color.setCurrentFrame(0); // Black
+ // // Is it unlocked?
+ // if (!isUnlocked)
+ // node->color.setCurrentFrame(0); // Black
- // Is it complete?
- else if ((exitComplete) || (secretComplete))
- // Does it have two exits?
- if ((node->hasSecret) && ((!exitComplete) || (!secretComplete)))
- node->color.setCurrentFrame(2); // Yellow
+ // // Is it complete?
+ // else if ((exitComplete) || (secretComplete))
+ // // Does it have two exits?
+ // if ((node->hasSecret) && ((!exitComplete) || (!secretComplete)))
+ // node->color.setCurrentFrame(2); // Yellow
- // All exits are complete
- else
- node->color.setCurrentFrame(1); // Blue
+ // // All exits are complete
+ // else
+ // node->color.setCurrentFrame(1); // Blue
- // Not complete after all
- else
- node->color.setCurrentFrame(3); // Red
+ // // Not complete after all
+ // else
+ // node->color.setCurrentFrame(3); // Red
- node->matrix.translation(node->x, node->y, 500.0);
- node->matrix.applyRotationYXZ(0, 0, 0);
- node->model.setDrawMatrix(node->matrix);
- node->model.setScale(1.0f, 1.0f, 1.0f);
- node->model.calcWorld(false);
+ // node->matrix.translation(node->x, node->y, 500.0);
+ // node->matrix.applyRotationYXZ(0, 0, 0);
+ // node->model.setDrawMatrix(node->matrix);
+ // node->model.setScale(1.0f, 1.0f, 1.0f);
+ // node->model.calcWorld(false);
- node->model.scheduleForDrawing();
- }
+ // node->model.scheduleForDrawing();
+ // }
}
diff --git a/src/koopatlas/mapdata.cpp b/src/koopatlas/mapdata.cpp
index 524fb4f..1fb8eb6 100644
--- a/src/koopatlas/mapdata.cpp
+++ b/src/koopatlas/mapdata.cpp
@@ -143,25 +143,27 @@ void dKPMapData_c::fixup() {
if (node->type == dKPNode_s::CHANGE)
fixRef(node->destMap);
- else if (node->type == dKPNode_s::LEVEL) {
- break;
- node->allocator.link(-1, GameHeaps[0], 0, 0x20);
+ // FORWARDS COMPATIBILITY:
+ // else if (node->type == dKPNode_s::LEVEL) {
+ // break;
- nw4r::g3d::ResFile rf(nodeLoader.buffer);
- rf.CheckRevision();
- rf.Init();
- rf.Bind(rf);
+ // node->allocator.link(-1, GameHeaps[0], 0, 0x20);
- nw4r::g3d::ResMdl mdl = rf.GetResMdl("cobCourse");
- nw4r::g3d::ResAnmVis anmRes = rf.GetResAnmVis("cobCourse");
+ // nw4r::g3d::ResFile rf(nodeLoader.buffer);
+ // rf.CheckRevision();
+ // rf.Init();
+ // rf.Bind(rf);
- node->model.setup(mdl, &node->allocator, 0x224, 1, 0);
- node->color.setup(mdl, anmRes, &node->allocator, 0);
- node->color.bind(&node->model, anmRes, 0);
- node->model.bindAnim(&node->color, 0.0f);
- SetupTextures_MapObj(&node->model, 0);
- }
+ // nw4r::g3d::ResMdl mdl = rf.GetResMdl("cobCourse");
+ // nw4r::g3d::ResAnmVis anmRes = rf.GetResAnmVis("cobCourse");
+
+ // node->model.setup(mdl, &node->allocator, 0x224, 1, 0);
+ // node->color.setup(mdl, anmRes, &node->allocator, 0);
+ // node->color.bind(&node->model, anmRes, 0);
+ // node->model.bindAnim(&node->color, 0.0f);
+ // SetupTextures_MapObj(&node->model, 0);
+ // }
}
break;
}
diff --git a/src/koopatlas/mapdata.h b/src/koopatlas/mapdata.h
index bb9e6c8..8a199a6 100644
--- a/src/koopatlas/mapdata.h
+++ b/src/koopatlas/mapdata.h
@@ -29,7 +29,8 @@ struct dKPDoodad_s {
int frameCount;
AnimTypes type;
int start, end;
- int delay, delayOffset;
+ // FORWARDS COMPATIBILITY:
+ // int delay, delayOffset;
u32 baseTick;
bool isReversed;
@@ -68,7 +69,9 @@ struct dKPNode_s {
NodeTypes type;
union {
- struct { u8 levelNumber[2]; bool hasSecret; };
+ struct { u8 levelNumber[2]; };
+ // FORWARDS COMPATIBILITY:
+ // struct { u8 levelNumber[2]; bool hasSecret; };
struct { const char *destMap; u8 thisID, foreignID, transition, _; };
};
@@ -81,10 +84,13 @@ struct dKPNode_s {
dKPPath_s *getOppositeExitTo(dKPPath_s *path);
- mHeapAllocator_c allocator;
- m3d::mdl_c model;
- m3d::anmVis_c color;
- mMtx matrix;
+
+ // FORWARDS COMPATIBILITY:
+
+ // mHeapAllocator_c allocator;
+ // m3d::mdl_c model;
+ // m3d::anmVis_c color;
+ // mMtx matrix;
};
struct dKPPath_s {