diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/koopatlas/core.cpp | 25 | ||||
-rw-r--r-- | src/koopatlas/hud.cpp | 275 | ||||
-rw-r--r-- | src/koopatlas/hud.h | 11 | ||||
-rw-r--r-- | src/koopatlas/player.cpp | 1 |
4 files changed, 287 insertions, 25 deletions
diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp index 4a0d190..eefde51 100644 --- a/src/koopatlas/core.cpp +++ b/src/koopatlas/core.cpp @@ -222,7 +222,7 @@ bool WMInit_SetupExtra(void *ptr) { // need Player before we can set up paths SpammyReport("creating player\n"); wm->player = (daWMPlayer_c*)CreateParentedObject(WM_PLAYER, wm, 0, 2); - wm->player->modelHandler->mdlClass->setPowerup(2); + wm->player->modelHandler->mdlClass->setPowerup(Player_Powerup[0]); wm->player->modelHandler->mdlClass->startAnimation(0, 1.2f, 10.0f, 0.0f); // since we've got all the resources, set up the path data too @@ -310,6 +310,13 @@ int dScKoopatlas_c::onCreate() { SpammyReport("GameSetup__LoadScene(0)\n"); GameSetup__LoadScene(0); // lol, stolen from GAME_SETUP + SpammyReport("Setting Active Players\n"); + for (int i = 0; i < 4; i++) { + bool isThere = QueryPlayerAvailability(i); + int id = Player_ID[i]; + Player_Active[i] = isThere ? 1 : 0; + if (!isThere) Player_Flags[i] = 0; + } SpammyReport("select cursor\n"); this->selectCursor = CreateParentedObject(SELECT_CURSOR, this, 0, 0); @@ -589,6 +596,14 @@ void dScKoopatlas_c::executeState_PlayerChangeWait() { } } else { if (!NPCHG_ACTIVE(this->numPeopleChange)) { + + for (int i = 0; i < 4; i++) { + bool isThere = QueryPlayerAvailability(i); + int id = Player_ID[i]; + Player_Active[i] = isThere ? 1 : 0; + if (!isThere) Player_Flags[i] = 0; + } + state.setState(&StateID_Normal); } } @@ -623,6 +638,8 @@ void dScKoopatlas_c::executeState_EasyPairingWait() { void dScKoopatlas_c::executeState_PowerupsWait() { if (!STKI_SHOW(this->stockItem)) { + dScKoopatlas_c::instance->player->modelHandler->mdlClass->setPowerup(Player_Powerup[0]); + state.setState(&StateID_Normal); } @@ -833,12 +850,6 @@ void dScKoopatlas_c::executeState_SaveError() { } void dScKoopatlas_c::startLevel(dLevelInfo_c::entry_s *entry) { - for (int i = 0; i < 4; i++) { - bool isThere = QueryPlayerAvailability(i); - int id = Player_ID[i]; - Player_Active[i] = isThere ? 1 : 0; - if (!isThere) Player_Flags[i] = 0; - } StartLevelInfo sl; sl.unk1 = 0; diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index c20f026..286bbf5 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -1,5 +1,7 @@ #include "koopatlas/hud.h" +void CharToWChar(const char *input, wchar_t *output, int length) { for (int i = 0; i < length; i++) output[i] = input[i]; } + dWMHud_c *dWMHud_c::instance = 0; dWMHud_c *dWMHud_c::build() { @@ -54,10 +56,12 @@ int dWMHud_c::onCreate() { layout.disableAllAnimations(); layout.enableNonLoopAnim(ANIM_BOTTOM_SHOW); - showPointBar(); + hidePointBar(); + setWorldText(" "); + setWorldName(); if (dScKoopatlas_c::instance->pathManager.mustComplainToMapCreator) - dWMHud_c::instance->setText("Please Fix Your Missing Entrance. Thanks"); + dWMHud_c::instance->setLevelText("Please Fix Your Missing Entrance. Thanks"); layoutLoaded = true; } @@ -72,6 +76,11 @@ int dWMHud_c::onDelete() { int dWMHud_c::onExecute() { + updateLives(); + setWorldName(); + checkPointStatus(); + setPointName(); + layout.execAnimations(); layout.update(); @@ -86,14 +95,41 @@ int dWMHud_c::onDraw() { } -void dWMHud_c::updateText() { - setPointName(); -} +void dWMHud_c::updateLives() { + + static const char *textID[4] = {"M", "L", "B", "Y"}; + static const char *picID[4] = {"P_mariopic", "P_luigipic", "P_toadBlue", "P_toadyellow"}; + + for (int i = 0; i < 4; i++) { + char boxName [13]; + sprintf(boxName, "T_%slifes_01", textID[i]); + nw4r::lyt::TextBox *box = layout.findTextBoxByName(boxName); + nw4r::lyt::Pane *pic = layout.findPictureByName(picID[i]); -void dWMHud_c::setText(const char *str, int length) { + if (Player_Active[i] != 0) { + box->alpha = 0xFF; + pic->alpha = 0xFF; + + char lives [3]; + sprintf(lives, "%02d", Player_Lives[Player_ID[i]]); + const char *loaves = lives; + wchar_t life; + + CharToWChar(loaves, &life, 3); + + box->SetString(&life); + } + else { + box->alpha = 0; + pic->alpha = 0; + } + } +} + +void dWMHud_c::setLevelText(const char *str, int length) { if (str == 0) { - setText("--NULL STRING--"); + setLevelText("--NULL STRING--"); return; } @@ -109,13 +145,12 @@ void dWMHud_c::setText(const char *str, int length) { } newString[i] = 0; - setText(newString, i); + setLevelText(newString, i); } - -void dWMHud_c::setText(const wchar_t *str, int length) { +void dWMHud_c::setLevelText(const wchar_t *str, int length) { if (str == 0) { - setText("--NULL STRING--"); + setLevelText("--NULL STRING--"); return; } @@ -152,12 +187,224 @@ void dWMHud_c::setPointName() { 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)); + setLevelText(li->getNameForLevel(entry)); } else { - setText(""); + setLevelText(" "); + hidePointBar(); + } +} + +void dWMHud_c::checkPointStatus() { + dKPNode_s *node = dScKoopatlas_c::instance->pathManager.currentNode; + + if (node->type == dKPNode_s::LEVEL) { + SaveBlock *save = GetSaveFile()->GetBlock(-1); + + int world = node->levelNumber[0]; + int level = node->levelNumber[1]; + + u32 conds = save->GetLevelCondition(world-1, level-1); + nw4r::lyt::Pane *pic; + + if (conds & COND_COIN1) { + pic = layout.findPictureByName("P_coin_on_01"); + pic->alpha = 0xFF; + + pic = layout.findPictureByName("P_coin_off_01"); + pic->alpha = 0; + } + else { + pic = layout.findPictureByName("P_coin_on_01"); + pic->alpha = 0; + + pic = layout.findPictureByName("P_coin_off_01"); + pic->alpha = 0xFF; + } + + if (conds & COND_COIN2) { + pic = layout.findPictureByName("P_coin_on_02"); + pic->alpha = 0xFF; + + pic = layout.findPictureByName("P_coin_off_02"); + pic->alpha = 0; + } + else { + pic = layout.findPictureByName("P_coin_on_02"); + pic->alpha = 0; + + pic = layout.findPictureByName("P_coin_off_02"); + pic->alpha = 0xFF; + } + + if (conds & COND_COIN3) { + pic = layout.findPictureByName("P_coin_on_03"); + pic->alpha = 0xFF; + + pic = layout.findPictureByName("P_coin_off_03"); + pic->alpha = 0; + } + else { + pic = layout.findPictureByName("P_coin_on_03"); + pic->alpha = 0; + + pic = layout.findPictureByName("P_coin_off_03"); + pic->alpha = 0xFF; + } + + if (conds & COND_NORMAL) { + pic = layout.findPictureByName("P_normalexitflag"); + pic->alpha = 0xFF; + } + else { + pic = layout.findPictureByName("P_normalexitflag"); + pic->alpha = 0; + } + + if (conds & COND_SECRET) { + pic = layout.findPictureByName("P_secretexitflag"); + pic->alpha = 0xFF; + } + else { + pic = layout.findPictureByName("P_secretexitflag"); + pic->alpha = 0; + } + + } else { + nw4r::lyt::Pane *pic; + + static const char *picNames[8] = {"P_coin_on_01", "P_coin_off_01", "P_coin_on_02", "P_coin_off_02", + "P_coin_on_03", "P_coin_off_03", "P_normalexitflag", "P_secretexitflag"}; + + for (int i = 0; i < 8; i++) { + pic = layout.findPictureByName(picNames[i]); + pic->alpha = 0; + } } } +void dWMHud_c::setWorldText(const char *str, int length) { + if (str == 0) { + setWorldText("--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; + + setWorldText(newString, i); +} + +void dWMHud_c::setWorldText(const wchar_t *str, int length) { + if (str == 0) { + setWorldText("--NULL STRING--"); + return; + } + + if (length == -1) { + length = wcslen(str); + } + + nw4r::lyt::TextBox *box = layout.findTextBoxByName("T_area_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); + + box->SetString(str); +} + +void dWMHud_c::setWorldName() { + // figure this out... + dKPNode_s *node = dScKoopatlas_c::instance->pathManager.currentNode; + + if (node->type == dKPNode_s::LEVEL) { + int world = node->levelNumber[0]; + int level = node->levelNumber[1]; + + switch (world) { + case 1: + setWorldText("Yoshi's\nIsland"); + break; + + case 2: + if (((level > 1) && (level < 5)) || (level == 15) || (level == 33) || (level == 34)) + setWorldText("Soggy\nSewers"); + else + setWorldText("Rubble\nRuins"); + break; + + case 3: + setWorldText("Mushroom\nPeaks"); + break; + + case 4: + setWorldText("Sakura\nVillage"); + break; + + case 5: + if ((level < 6) || (level == 15) || (level == 33) || (level == 34)) + setWorldText("Freeze Flame\nValley"); + else + setWorldText("Freeze Flame\nVolcano"); + break; + + case 6: + setWorldText("Ghost\nRealm"); + break; + + case 7: + if (level < 4) + setWorldText("Sky\nMountain"); + else + setWorldText("Starry\nSkies"); + break; + + case 8: + if ((level < 6) || (level == 15) || (level == 25) || (level == 33) || (level == 34)) + setWorldText("Koopa\nPlanet"); + else + setWorldText("Koopa\nCore"); + break; + + case 9: + setWorldText("Bonus\nLand"); + break; + + case 10: + if ((level < 6) || (level == 33) || (level == 34)) + setWorldText("Goldwood\nForest"); + else if ((level < 11) || (level == 35) || (level == 36)) + setWorldText("Mini-Mega\nIsland"); + else if ((level < 16) || (level == 37) || (level == 38) || (level == 31) ) + setWorldText("Crystal\nCaves"); + else if ((level < 19) || (level == 39) || (level == 40)) + setWorldText("Bombard\nCliffs"); + else + setWorldText("Sky\nCity"); + break; + + default: + setWorldText("Unknown\nWorld"); + break; + } + } +} void dWMHud_c::showPointBar() { dKPNode_s *node = dScKoopatlas_c::instance->pathManager.currentNode; @@ -165,8 +412,6 @@ void dWMHud_c::showPointBar() { if (node->type == dKPNode_s::LEVEL) { isPointBarShown = true; - updateText(); - layout.enableNonLoopAnim(ANIM_TOP_SHOW); } } diff --git a/src/koopatlas/hud.h b/src/koopatlas/hud.h index 8d964c5..347fcb4 100644 --- a/src/koopatlas/hud.h +++ b/src/koopatlas/hud.h @@ -15,14 +15,19 @@ class dWMHud_c : public dBase_c { bool layoutLoaded; m2d::EmbedLayout_c layout; - void updateText(); + void updateLives(); void showPointBar(); void hidePointBar(); void setPointName(); - void setText(const char *str, int length = -1); - void setText(const wchar_t *str, int length = -1); + void checkPointStatus(); + void setLevelText(const char *str, int length = -1); + void setLevelText(const wchar_t *str, int length = -1); + + void setWorldName(); + void setWorldText(const char *str, int length = -1); + void setWorldText(const wchar_t *str, int length = -1); static dWMHud_c *build(); static dWMHud_c *instance; diff --git a/src/koopatlas/player.cpp b/src/koopatlas/player.cpp index 709fe43..f8e491a 100644 --- a/src/koopatlas/player.cpp +++ b/src/koopatlas/player.cpp @@ -5,6 +5,7 @@ daWMPlayer_c *daWMPlayer_c::instance; int daWMPlayer_c::onCreate() { this->modelHandler = new dPlayerModelHandler_c(0); + // loadModel(u8 player_id, int powerup_id, int unk); this->modelHandler->loadModel(0, 3, 2); this->modelHandler->mdlClass->startAnimation(0, 1.2, 10.0, 0.0); this->modelHandler->setSRT((Vec){0.0,100.0,-100.0}, (S16Vec){0,0,0}, (Vec){2.0,2.0,2.0}); |