From 05eb1400faaa957905fbbe8fa284df4ab1472a58 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 20 Sep 2012 15:30:05 +0200 Subject: cleaning up in preparation for the new HUD, plus a few other changes --- src/koopatlas/hud.cpp | 339 ------------------------------------------ src/koopatlas/hud.h | 17 --- src/koopatlas/pathmanager.cpp | 5 - src/koopatlas/shop.cpp | 22 +-- src/koopatlas/starcoin.cpp | 22 +-- 5 files changed, 2 insertions(+), 403 deletions(-) (limited to 'src/koopatlas') diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index 3989a1c..bdd51b0 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -1,28 +1,5 @@ #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]; } - -int getStarCoinCount() { - - SaveBlock *save = GetSaveFile()->GetBlock(-1); - int coinsSpent = save->credits_hiscore; - 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() { @@ -40,14 +17,6 @@ dWMHud_c::dWMHud_c() { } -// 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); @@ -73,14 +42,6 @@ int dWMHud_c::onCreate() { layout.loadAnimations(brlanNames, 5); layout.loadGroups(groupNames, (int[6]){0, 0, 1, 2, 3, 4}, 6); layout.disableAllAnimations(); - layout.enableNonLoopAnim(ANIM_BOTTOM_SHOW); - - hidePointBar(); - setWorldText(" "); - setWorldName(); - - if (dScKoopatlas_c::instance->pathManager.mustComplainToMapCreator) - dWMHud_c::instance->setLevelText("Please Fix Your Missing Entrance. Thanks"); layoutLoaded = true; } @@ -95,11 +56,6 @@ int dWMHud_c::onDelete() { int dWMHud_c::onExecute() { - updateLives(); - setWorldName(); - checkPointStatus(); - setPointName(); - layout.execAnimations(); layout.update(); @@ -113,298 +69,3 @@ int dWMHud_c::onDraw() { return true; } - -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]); - - 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; - } - } - - 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) { - if (str == 0) { - setLevelText("--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; - - setLevelText(newString, i); -} - -void dWMHud_c::setLevelText(const wchar_t *str, int length) { - if (str == 0) { - setLevelText("--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); - - setLevelText(li->getNameForLevel(entry)); - } else { - setLevelText(" "); - hidePointBar(); - } -} - -void dWMHud_c::checkPointStatus() { - dKPNode_s *node = dScKoopatlas_c::instance->pathManager.currentNode; - - if ((node->type == dKPNode_s::LEVEL) && ((node->levelNumber[1] < 30) || (node->levelNumber[1] > 37))) { - 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; - } - - 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; - - 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; - } - - nw4r::lyt::TextBox *deathbox = layout.findTextBoxByName("T_death_01"); - wchar_t noDie; - CharToWChar("---", &noDie, 4); - deathbox->SetString(&noDie); - } -} - -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]; - - setWorldText(NewerWorldName(NewerWorldForLevelID(world, level))); - } -} - -void dWMHud_c::showPointBar() { - dKPNode_s *node = dScKoopatlas_c::instance->pathManager.currentNode; - - if (node->type == dKPNode_s::LEVEL) { - isPointBarShown = true; - - layout.enableNonLoopAnim(ANIM_TOP_SHOW); - } -} - - -void dWMHud_c::hidePointBar() { - if (isPointBarShown) { - isPointBarShown = false; - - layout.enableNonLoopAnim(ANIM_TOP_HIDE); - } -} - - - diff --git a/src/koopatlas/hud.h b/src/koopatlas/hud.h index 347fcb4..ac7b81e 100644 --- a/src/koopatlas/hud.h +++ b/src/koopatlas/hud.h @@ -15,25 +15,8 @@ class dWMHud_c : public dBase_c { bool layoutLoaded; m2d::EmbedLayout_c layout; - void updateLives(); - - void showPointBar(); - void hidePointBar(); - - void setPointName(); - 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; - - private: - bool isPointBarShown; }; #endif diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 49ee728..3d85f4c 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -300,8 +300,6 @@ void dWMPathManager_c::execute() { void dWMPathManager_c::startMovementTo(dKPPath_s *path) { SpammyReport("moving to path %p\n", path); - dWMHud_c::instance->hidePointBar(); - SpammyReport("point bar hidden\n"); if (!path->isAvailable) { return; } @@ -566,9 +564,6 @@ void dWMPathManager_c::moveThroughPath() { save->currentNewerWorld = (u8)nWorld; } } - - dWMHud_c::instance->showPointBar(); - SpammyReport("Point bar shown\n"); } else { startMovementTo(to->getOppositeAvailableExitTo(currentPath)); SpammyReport("passthrough node, continuing to next path\n"); diff --git a/src/koopatlas/shop.cpp b/src/koopatlas/shop.cpp index eed0222..29a96b0 100644 --- a/src/koopatlas/shop.cpp +++ b/src/koopatlas/shop.cpp @@ -1,26 +1,6 @@ #include "koopatlas/shop.h" -int getStarCoinCountShop() { - SaveBlock *save = GetSaveFile()->GetBlock(-1); - int coinsSpent = save->credits_hiscore; - 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; -} - - const char* Produce[10][4] = { { "I_kinoko", "g3d/I_kinoko.brres", "I_kinoko", "wait2" }, { "I_fireflower", "g3d/I_fireflower.brres", "I_fireflower", "wait2" }, @@ -373,7 +353,7 @@ void dWMShop_c::BuyItem(int item) { layout.enableNonLoopAnim(item-1); - int cash = getStarCoinCountShop(); + int cash = getStarCoinCount(); int cost; int Powerups[10]; diff --git a/src/koopatlas/starcoin.cpp b/src/koopatlas/starcoin.cpp index 54b7218..d4bdbd8 100644 --- a/src/koopatlas/starcoin.cpp +++ b/src/koopatlas/starcoin.cpp @@ -1,26 +1,6 @@ #include "koopatlas/starcoin.h" #include -int getStarCoinCountCoins() { - SaveBlock *save = GetSaveFile()->GetBlock(-1); - int coinsSpent = save->credits_hiscore; - 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; -} - - /*****************************************************************************/ // Starcoin Layout // @@ -227,7 +207,7 @@ void dWMStarCoin::LoadCoinsForWorld(int world) { // Display Total Star Coin Count - int myCoins = getStarCoinCountCoins(); + int myCoins = getStarCoinCount(); char myCoinsStr [4]; sprintf(myCoinsStr, "%03d", myCoins); -- cgit v1.2.3 From f21117a1ebb837fec02b42a3808896d6edb4ccf6 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 20 Sep 2012 17:29:47 +0200 Subject: beginnings of the new HUD --- src/koopatlas/hud.cpp | 48 +++++++++++++++++++++++++++++++++++++++++------- src/koopatlas/hud.h | 7 +++++++ 2 files changed, 48 insertions(+), 7 deletions(-) (limited to 'src/koopatlas') diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index bdd51b0..b7e40d2 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -16,17 +16,19 @@ dWMHud_c::dWMHud_c() { layoutLoaded = false; } +enum WMHudAnimation { + SHOW_LIVES = 0, + SHOW_HEADER, + SHOW_FOOTER +}; + int dWMHud_c::onCreate() { if (!layoutLoaded) { - bool gotFile = layout.loadArc("maphud.arc", false); + 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()) { @@ -39,10 +41,19 @@ int dWMHud_c::onCreate() { layout.layout.rootPane->scale.y = 0.7711f; } - layout.loadAnimations(brlanNames, 5); - layout.loadGroups(groupNames, (int[6]){0, 0, 1, 2, 3, 4}, 6); + static const char *brlanNames[2] = {"MapHUD_ShowMain.brlan", "MapHUD_ShowHeader.brlan"}; + static const char *groupNames[3] = {"G_Lives", "G_Header", "G_Footer"}; + + layout.loadAnimations(brlanNames, 2); + layout.loadGroups(groupNames, (int[3]){0, 1, 0}, 3); layout.disableAllAnimations(); + layout.enableNonLoopAnim(SHOW_LIVES); + layout.enableNonLoopAnim(SHOW_FOOTER); + + static const char *tbNames[2] = {"MenuButtonInfo", "ItemsButtonInfo"}; + layout.setLangStrings(tbNames, (int[2]){12, 15}, 4, 2); + layoutLoaded = true; } @@ -51,11 +62,17 @@ int dWMHud_c::onCreate() { int dWMHud_c::onDelete() { + if (!layoutLoaded) + return true; + return layout.free(); } int dWMHud_c::onExecute() { + if (!layoutLoaded) + return true; + layout.execAnimations(); layout.update(); @@ -64,8 +81,25 @@ int dWMHud_c::onExecute() { int dWMHud_c::onDraw() { + if (!layoutLoaded) + return true; + layout.scheduleForDrawing(); return true; } + + + +void dWMHud_c::playShowHeaderAnim() { + layout.enableNonLoopAnim(SHOW_HEADER); +} + +void dWMHud_c::playHideHeaderAnim() { + if (layout.isAnimOn(SHOW_HEADER)) { + layout.enableNonLoopAnim(SHOW_HEADER, true); + } + layout.grpHandlers[SHOW_HEADER].frameCtrl.flags = 2; // NO_LOOP | REVERSE +} + diff --git a/src/koopatlas/hud.h b/src/koopatlas/hud.h index ac7b81e..87f731b 100644 --- a/src/koopatlas/hud.h +++ b/src/koopatlas/hud.h @@ -17,6 +17,13 @@ class dWMHud_c : public dBase_c { static dWMHud_c *build(); static dWMHud_c *instance; + + + bool showingHeader; + + + void playShowHeaderAnim(); + void playHideHeaderAnim(); }; #endif -- cgit v1.2.3 From badb2bf6bc25f47e711fc483e0c551b4fc18759f Mon Sep 17 00:00:00 2001 From: Treeki Date: Fri, 21 Sep 2012 00:08:14 +0200 Subject: fixes, header cleanups, and part of the code for the new HUD --- src/koopatlas/hud.cpp | 122 ++++++++++++++++++++++++++++++++++++++++++++- src/koopatlas/hud.h | 18 ++++++- src/koopatlas/starcoin.cpp | 4 +- 3 files changed, 138 insertions(+), 6 deletions(-) (limited to 'src/koopatlas') diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index b7e40d2..266c284 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -54,7 +54,24 @@ int dWMHud_c::onCreate() { static const char *tbNames[2] = {"MenuButtonInfo", "ItemsButtonInfo"}; layout.setLangStrings(tbNames, (int[2]){12, 15}, 4, 2); + static const char *pictureNames[7] = { + "Header_Centre", "Header_Right", + "NormalExitFlag", "SecretExitFlag", + "StarCoinOn0", "StarCoinOn1", "StarCoinOn2" + }; + layout.getPictures(pictureNames, &Header_Centre, 7); + + static const char *textBoxNames[7] = { + "LevelName", "LevelNameS", + "LevelNumber", "LevelNumberS", + "WorldName", "WorldNameS", + "StarCoinCounter" + }; + layout.getTextBoxes(textBoxNames, &LevelName, 7); + layoutLoaded = true; + + willShowHeader = false; } return true; @@ -73,6 +90,12 @@ int dWMHud_c::onExecute() { if (!layoutLoaded) return true; + if (willShowHeader && (!(layout.isAnimOn(SHOW_HEADER)))) { + willShowHeader = false; + loadHeaderInfo(); + playShowHeaderAnim(); + } + layout.execAnimations(); layout.update(); @@ -97,9 +120,104 @@ void dWMHud_c::playShowHeaderAnim() { } void dWMHud_c::playHideHeaderAnim() { - if (layout.isAnimOn(SHOW_HEADER)) { + if (!layout.isAnimOn(SHOW_HEADER)) { layout.enableNonLoopAnim(SHOW_HEADER, true); } - layout.grpHandlers[SHOW_HEADER].frameCtrl.flags = 2; // NO_LOOP | REVERSE + layout.grpHandlers[SHOW_HEADER].frameCtrl.flags = 3; // NO_LOOP | REVERSE +} + + +void dWMHud_c::loadHeaderInfo() { + dLevelInfo_c *levelInfo = &dScKoopatlas_c::instance->levelInfo; + + dLevelInfo_c::entry_s *infEntry = levelInfo->search( + nodeForHeader->levelNumber[0], nodeForHeader->levelNumber[1]); + + if (infEntry == 0) { + LevelName->SetString(L"Unknown Level Name!"); + LevelNameS->SetString(L"Unknown Level Name!"); + return; + } + + // LEVEL NAME + wchar_t convertedLevelName[100]; + const char *sourceLevelName = levelInfo->getNameForLevel(infEntry); + int charCount = 0; + + while (*sourceLevelName != 0 && charCount < 99) { + convertedLevelName[charCount] = *sourceLevelName; + sourceLevelName++; + charCount++; + } + convertedLevelName[charCount] = 0; + + LevelName->SetString(convertedLevelName); + LevelNameS->SetString(convertedLevelName); + + // LEVEL NUMBER + wchar_t levelNumber[6]; + levelNumber[0] = '0' + nodeForHeader->levelNumber[0]; + levelNumber[1] = '-'; + if (nodeForHeader->levelNumber[1] >= 10) { + levelNumber[2] = '0' + (nodeForHeader->levelNumber[1] / 10); + levelNumber[3] = '0' + (nodeForHeader->levelNumber[1] % 10); + levelNumber[4] = 0; + } else { + levelNumber[2] = '0' + nodeForHeader->levelNumber[1]; + levelNumber[3] = 0; + } + + LevelNumber->SetString(levelNumber); + LevelNumberS->SetString(levelNumber); + + // INFO + int w = nodeForHeader->levelNumber[0] - 1; + int l = nodeForHeader->levelNumber[1] - 1; + + u32 conds = GetSaveFile()->GetBlock(-1)->GetLevelCondition(w, l); + NormalExitFlag->SetVisible(conds & COND_NORMAL); + SecretExitFlag->SetVisible(conds & COND_SECRET); + StarCoinOn[0]->SetVisible(conds & COND_COIN1); + StarCoinOn[1]->SetVisible(conds & COND_COIN2); + StarCoinOn[2]->SetVisible(conds & COND_COIN3); + + // SIZE THING + nw4r::ut::TextWriter tw; + tw.font = LevelName->font; + tw.SetFontSize(LevelName->fontSizeX, LevelName->fontSizeY); + tw.lineSpace = LevelName->lineSpace; + tw.charSpace = LevelName->charSpace; + if (LevelName->tagProc != 0) + tw.tagProcessor = LevelName->tagProc; + + float width = tw.CalcStringWidth(convertedLevelName, charCount); + Header_Centre->size.x = width + LevelName->trans.x - 20.0f; + Header_Right->trans.x = Header_Centre->size.x; +} + + + +void dWMHud_c::enteredNode() { + dKPNode_s *node = dScKoopatlas_c::instance->pathManager.currentNode; + + if (node->type == dKPNode_s::LEVEL) { + willShowHeader = true; + nodeForHeader = node; + } +} + +void dWMHud_c::leftNode() { + if (layout.grpHandlers[SHOW_HEADER].frameCtrl.currentFrame > 0.1f) { + // not hidden + + if ((layout.isAnimOn(SHOW_HEADER) && (layout.grpHandlers[SHOW_HEADER].frameCtrl.flags & 2)) + || (!layout.isAnimOn(SHOW_HEADER))) { + // currently being shown, OR fully shown already + playHideHeaderAnim(); + } + } } + + + diff --git a/src/koopatlas/hud.h b/src/koopatlas/hud.h index 87f731b..632a078 100644 --- a/src/koopatlas/hud.h +++ b/src/koopatlas/hud.h @@ -19,11 +19,25 @@ class dWMHud_c : public dBase_c { static dWMHud_c *instance; - bool showingHeader; - + void enteredNode(); + void leftNode(); + private: void playShowHeaderAnim(); void playHideHeaderAnim(); + void loadHeaderInfo(); + + bool willShowHeader; + dKPNode_s *nodeForHeader; + + + nw4r::lyt::Picture *Header_Centre, *Header_Right; + nw4r::lyt::Picture *NormalExitFlag, *SecretExitFlag; + nw4r::lyt::Picture *StarCoinOn[3]; + nw4r::lyt::TextBox *LevelName, *LevelNameS; + nw4r::lyt::TextBox *LevelNumber, *LevelNumberS; + nw4r::lyt::TextBox *WorldName, *WorldNameS; + nw4r::lyt::TextBox *StarCoinCounter; }; #endif diff --git a/src/koopatlas/starcoin.cpp b/src/koopatlas/starcoin.cpp index d4bdbd8..3842f87 100644 --- a/src/koopatlas/starcoin.cpp +++ b/src/koopatlas/starcoin.cpp @@ -326,10 +326,10 @@ void dWMStarCoin::setText(const char *str, const char *name) { nw4r::ut::TextWriter tw; tw.font = box->font; tw.SetFontSize(box->fontSizeX, box->fontSizeY); - tw.somethingRelatedToLineHeight = box->lineSpace; + tw.lineSpace = box->lineSpace; tw.charSpace = box->charSpace; if (box->tagProc != 0) - tw.tagProcessorMaybe = box->tagProc; + tw.tagProcessor = box->tagProc; float width = tw.CalcStringWidth(newString, wlength); SpammyReport("Text width: %f\n", width); -- cgit v1.2.3 From 955831a5bad45d39dfceb4a1741095b5d109b079 Mon Sep 17 00:00:00 2001 From: Treeki Date: Fri, 21 Sep 2012 13:24:57 +0200 Subject: still working on the new HUD... --- src/koopatlas/core.h | 2 +- src/koopatlas/hud.cpp | 18 +++++++++++++----- src/koopatlas/hud.h | 2 +- src/koopatlas/pathmanager.cpp | 18 ++++++++++++++++++ src/koopatlas/pathmanager.h | 2 ++ 5 files changed, 35 insertions(+), 7 deletions(-) (limited to 'src/koopatlas') diff --git a/src/koopatlas/core.h b/src/koopatlas/core.h index 2674977..fd3e15c 100644 --- a/src/koopatlas/core.h +++ b/src/koopatlas/core.h @@ -18,7 +18,7 @@ #include "koopatlas/pathmanager.h" #define WM_DEBUGGING -// #define WM_SPAMMY_DEBUGGING +#define WM_SPAMMY_DEBUGGING #ifdef WM_DEBUGGING #define MapReport OSReport diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index 266c284..cd52beb 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -50,6 +50,7 @@ int dWMHud_c::onCreate() { layout.enableNonLoopAnim(SHOW_LIVES); layout.enableNonLoopAnim(SHOW_FOOTER); + layout.resetAnim(SHOW_HEADER); static const char *tbNames[2] = {"MenuButtonInfo", "ItemsButtonInfo"}; layout.setLangStrings(tbNames, (int[2]){12, 15}, 4, 2); @@ -72,6 +73,9 @@ int dWMHud_c::onCreate() { layoutLoaded = true; willShowHeader = false; + + if (!dScKoopatlas_c::instance->pathManager.isMoving) + enteredNode(); } return true; @@ -131,7 +135,7 @@ void dWMHud_c::loadHeaderInfo() { dLevelInfo_c *levelInfo = &dScKoopatlas_c::instance->levelInfo; dLevelInfo_c::entry_s *infEntry = levelInfo->search( - nodeForHeader->levelNumber[0], nodeForHeader->levelNumber[1]); + nodeForHeader->levelNumber[0]-1, nodeForHeader->levelNumber[1]-1); if (infEntry == 0) { LevelName->SetString(L"Unknown Level Name!"); @@ -191,14 +195,18 @@ void dWMHud_c::loadHeaderInfo() { tw.tagProcessor = LevelName->tagProc; float width = tw.CalcStringWidth(convertedLevelName, charCount); - Header_Centre->size.x = width + LevelName->trans.x - 20.0f; - Header_Right->trans.x = Header_Centre->size.x; + float totalWidth = width + LevelName->trans.x - 20.0f; + if (totalWidth < 270.0f) + totalWidth = 270.0f; + Header_Centre->size.x = totalWidth; + Header_Right->trans.x = totalWidth; } -void dWMHud_c::enteredNode() { - dKPNode_s *node = dScKoopatlas_c::instance->pathManager.currentNode; +void dWMHud_c::enteredNode(dKPNode_s *node) { + if (node == 0) + node = dScKoopatlas_c::instance->pathManager.currentNode; if (node->type == dKPNode_s::LEVEL) { willShowHeader = true; diff --git a/src/koopatlas/hud.h b/src/koopatlas/hud.h index 632a078..6f10169 100644 --- a/src/koopatlas/hud.h +++ b/src/koopatlas/hud.h @@ -19,7 +19,7 @@ class dWMHud_c : public dBase_c { static dWMHud_c *instance; - void enteredNode(); + void enteredNode(dKPNode_s *node = 0); void leftNode(); private: diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 3d85f4c..a03541c 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -302,6 +302,10 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) { SpammyReport("moving to path %p\n", path); if (!path->isAvailable) { return; } + if (currentNode) + dWMHud_c::instance->leftNode(); + + calledEnteredNode = false; SpammyReport("a\n"); isMoving = true; @@ -496,6 +500,18 @@ void dWMPathManager_c::moveThroughPath() { player->pos.x += move.x; player->pos.y -= move.y; + // what distance is left? + if (to->type == dKPNode_s::LEVEL && !calledEnteredNode) { + Vec toEndVec = {to->x - player->pos.x, to->y + player->pos.y, 0.0f}; + float distToEnd = VECMag(&toEndVec); + //OSReport("Distance: %f; To:%d,%d; Player:%f,%f; Diff:%f,%f\n", distToEnd, to->x, to->y, player->pos.x, player->pos.y, toEndVec.x, toEndVec.y); + + if (distToEnd < 64.0f) { + calledEnteredNode = true; + dWMHud_c::instance->enteredNode(to); + } + } + // Check if we've reached the end yet if ( ((move.x > 0) ? (player->pos.x >= to->x) : (player->pos.x <= to->x)) && @@ -557,6 +573,8 @@ void dWMPathManager_c::moveThroughPath() { SaveBlock *save = GetSaveFile()->GetBlock(-1); save->current_path_node = pathLayer->findNodeID(to); + if (!calledEnteredNode) + dWMHud_c::instance->enteredNode(); if (to->type == dKPNode_s::LEVEL) { NWRWorld nWorld = NewerWorldForLevelID(to->levelNumber[0], to->levelNumber[1]); diff --git a/src/koopatlas/pathmanager.h b/src/koopatlas/pathmanager.h index e010aa4..cae96ba 100644 --- a/src/koopatlas/pathmanager.h +++ b/src/koopatlas/pathmanager.h @@ -51,6 +51,8 @@ class dWMPathManager_c { bool evaluateUnlockCondition(u8 *&in, SaveBlock *save, int stack); bool isEnteringLevel; + + bool calledEnteredNode; }; #endif -- cgit v1.2.3 From 1d208821593eb4da0ea6bd801454be4535312e3a Mon Sep 17 00:00:00 2001 From: Treeki Date: Sat, 22 Sep 2012 05:18:52 +0200 Subject: quick fix for the HUD --- src/koopatlas/hud.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/koopatlas') diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index cd52beb..5fe8072 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -120,10 +120,14 @@ int dWMHud_c::onDraw() { void dWMHud_c::playShowHeaderAnim() { + if (!this || !this->layoutLoaded) return; + layout.enableNonLoopAnim(SHOW_HEADER); } void dWMHud_c::playHideHeaderAnim() { + if (!this || !this->layoutLoaded) return; + if (!layout.isAnimOn(SHOW_HEADER)) { layout.enableNonLoopAnim(SHOW_HEADER, true); } -- cgit v1.2.3 From aafa2a57c88c01067266244eae2a906d8771c065 Mon Sep 17 00:00:00 2001 From: Treeki Date: Sat, 22 Sep 2012 05:20:21 +0200 Subject: huh, I forgot to disable spammy debugging here --- src/koopatlas/core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/koopatlas') diff --git a/src/koopatlas/core.h b/src/koopatlas/core.h index 41fba45..2a69927 100644 --- a/src/koopatlas/core.h +++ b/src/koopatlas/core.h @@ -18,7 +18,7 @@ #include "koopatlas/pathmanager.h" #define WM_DEBUGGING -#define WM_SPAMMY_DEBUGGING +// #define WM_SPAMMY_DEBUGGING #ifdef WM_DEBUGGING #define MapReport OSReport -- cgit v1.2.3 From f4be7c3e4a44a6ec870eb61863a3d294da6f10ae Mon Sep 17 00:00:00 2001 From: Treeki Date: Tue, 25 Sep 2012 04:51:03 +0200 Subject: fixed display of lives --- src/koopatlas/hud.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++------ src/koopatlas/hud.h | 25 +++++++++++++++------- 2 files changed, 70 insertions(+), 13 deletions(-) (limited to 'src/koopatlas') diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index 5fe8072..b7effce 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -55,20 +55,30 @@ int dWMHud_c::onCreate() { static const char *tbNames[2] = {"MenuButtonInfo", "ItemsButtonInfo"}; layout.setLangStrings(tbNames, (int[2]){12, 15}, 4, 2); - static const char *pictureNames[7] = { + static const char *paneNames[] = { + "N_IconPos1P_00", "N_IconPos2P_00", + "N_IconPos3P_00", "N_IconPos4P_00" + }; + layout.getPanes(paneNames, &N_IconPosXP_00[0], 4); + + static const char *pictureNames[] = { "Header_Centre", "Header_Right", "NormalExitFlag", "SecretExitFlag", - "StarCoinOn0", "StarCoinOn1", "StarCoinOn2" + "StarCoinOn0", "StarCoinOn1", "StarCoinOn2", + "P_marioFace_00", "P_luigiFace_00", + "P_BkinoFace_00", "P_YkinoFace_00" }; - layout.getPictures(pictureNames, &Header_Centre, 7); + layout.getPictures(pictureNames, &Header_Centre, 11); - static const char *textBoxNames[7] = { + static const char *textBoxNames[] = { "LevelName", "LevelNameS", "LevelNumber", "LevelNumberS", "WorldName", "WorldNameS", - "StarCoinCounter" + "StarCoinCounter", + "T_lifeNumber_00", "T_lifeNumber_01", + "T_lifeNumber_02", "T_lifeNumber_03" }; - layout.getTextBoxes(textBoxNames, &LevelName, 7); + layout.getTextBoxes(textBoxNames, &LevelName, 11); layoutLoaded = true; @@ -76,6 +86,8 @@ int dWMHud_c::onCreate() { if (!dScKoopatlas_c::instance->pathManager.isMoving) enteredNode(); + + setupLives(); } return true; @@ -232,4 +244,38 @@ void dWMHud_c::leftNode() { +void dWMHud_c::setupLives() { + static const int LogicalPlayerIDs[] = {0,1,3,2}; + + P_marioFace_00->SetVisible(false); + P_luigiFace_00->SetVisible(false); + P_BkinoFace_00->SetVisible(false); + P_YkinoFace_00->SetVisible(false); + + int playerCount = 0; + + for (int i = 0; i < 4; i++) { + // The part in setupLives() + int playerID = LogicalPlayerIDs[i]; + int slotID = SearchForIndexOfPlayerID(playerID); + int lives = Player_Lives[slotID]; + int length = 2; + + WriteNumberToTextBox(&lives, &length, T_lifeNumber[slotID], true); + + // The part in setupIconThings() + if (QueryPlayerAvailability(slotID)) { + playerCount++; + + nw4r::lyt::Pane *facePane = (&P_marioFace_00)[playerID]; + facePane->trans = N_IconPosXP_00[i]->trans; + facePane->SetVisible(true); + } + } + + for (int i = 0; i < 4; i++) + N_IconPosXP_00[i]->SetVisible(false); + N_IconPosXP_00[playerCount - 1]->SetVisible(true); +} + diff --git a/src/koopatlas/hud.h b/src/koopatlas/hud.h index 6f10169..07dde77 100644 --- a/src/koopatlas/hud.h +++ b/src/koopatlas/hud.h @@ -22,6 +22,8 @@ class dWMHud_c : public dBase_c { void enteredNode(dKPNode_s *node = 0); void leftNode(); + void setupLives(); + private: void playShowHeaderAnim(); void playHideHeaderAnim(); @@ -31,13 +33,22 @@ class dWMHud_c : public dBase_c { dKPNode_s *nodeForHeader; - nw4r::lyt::Picture *Header_Centre, *Header_Right; - nw4r::lyt::Picture *NormalExitFlag, *SecretExitFlag; - nw4r::lyt::Picture *StarCoinOn[3]; - nw4r::lyt::TextBox *LevelName, *LevelNameS; - nw4r::lyt::TextBox *LevelNumber, *LevelNumberS; - nw4r::lyt::TextBox *WorldName, *WorldNameS; - nw4r::lyt::TextBox *StarCoinCounter; + nw4r::lyt::Pane + *N_IconPosXP_00[4]; + + nw4r::lyt::Picture + *Header_Centre, *Header_Right, + *NormalExitFlag, *SecretExitFlag, + *StarCoinOn[3], + *P_marioFace_00, *P_luigiFace_00, + *P_BkinoFace_00, *P_YkinoFace_00; + + nw4r::lyt::TextBox + *LevelName, *LevelNameS, + *LevelNumber, *LevelNumberS, + *WorldName, *WorldNameS, + *StarCoinCounter, + *T_lifeNumber[4]; }; #endif -- cgit v1.2.3 From 46b65dfd76411bec6f8356c581f337f8a1944013 Mon Sep 17 00:00:00 2001 From: Treeki Date: Tue, 25 Sep 2012 23:03:30 +0200 Subject: added Remocon and GameMgr definitions, and made map HUD buttons work --- src/koopatlas/hud.cpp | 18 ++++++++++++++++++ src/koopatlas/hud.h | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src/koopatlas') diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index b7effce..c9124d2 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -14,6 +14,7 @@ dWMHud_c *dWMHud_c::build() { dWMHud_c::dWMHud_c() { layoutLoaded = false; + displayedControllerType = -1; } enum WMHudAnimation { @@ -112,6 +113,8 @@ int dWMHud_c::onExecute() { playShowHeaderAnim(); } + updatePressableButtonThingies(); + layout.execAnimations(); layout.update(); @@ -278,4 +281,19 @@ void dWMHud_c::setupLives() { N_IconPosXP_00[playerCount - 1]->SetVisible(true); } +void dWMHud_c::updatePressableButtonThingies() { + int cntType = RemoconMng->controllers[0]->controllerType; + + if (cntType != displayedControllerType) { + displayedControllerType = cntType; + + int beef = (cntType == 0) ? 0 : 1; + GameMgrP->currentControllerType = beef; + + WriteBMGToTextBox( + layout.findTextBoxByName("ItemsButtonInfo"), + GetBMG(), 4, 15, 0); + } +} + diff --git a/src/koopatlas/hud.h b/src/koopatlas/hud.h index 07dde77..e507aea 100644 --- a/src/koopatlas/hud.h +++ b/src/koopatlas/hud.h @@ -18,7 +18,6 @@ class dWMHud_c : public dBase_c { static dWMHud_c *build(); static dWMHud_c *instance; - void enteredNode(dKPNode_s *node = 0); void leftNode(); @@ -32,6 +31,9 @@ class dWMHud_c : public dBase_c { bool willShowHeader; dKPNode_s *nodeForHeader; + int displayedControllerType; + void updatePressableButtonThingies(); + nw4r::lyt::Pane *N_IconPosXP_00[4]; -- cgit v1.2.3