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 --- include/game.h | 51 +++++++ include/newer.h | 1 + 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 +-- src/newer.cpp | 21 +++ 8 files changed, 75 insertions(+), 403 deletions(-) diff --git a/include/game.h b/include/game.h index 169b01d..7e8456d 100755 --- a/include/game.h +++ b/include/game.h @@ -3067,6 +3067,57 @@ namespace mHeap { }; void WriteNumberToTextBox(int *number, const int *fieldLength, nw4r::lyt::TextBox *textBox, bool unk); // 800B3B60 + +namespace EGG { + class MsgRes { + private: + const u8 *bmg, *INF1, *DAT1, *STR1, *MID1, *FLW1, *FLI1; + public: + MsgRes(const u8 *bmgFile, u32 unusedParam); // 802D7970 + virtual ~MsgRes(); + + static void parseFormatCode(wchar_t initialTag, const wchar_t *string, u8 *outArgsSize, u32 *outCmd, const wchar_t **args); // 802D7B10 + + const wchar_t *findStringForMessageID(int category, int message) const; // 0x802D7B50 + + private: + void setBMG(const u8 *ptr); // 802D7B90 + void setINF(const u8 *ptr); // 802D7BA0 + void setDAT(const u8 *ptr); // 802D7BB0 + void setSTR(const u8 *ptr); // 802D7BC0 + void setMID(const u8 *ptr); // 802D7BD0 + void setFLW(const u8 *ptr); // 802D7BE0 + void setFLI(const u8 *ptr); // 802D7BF0 + int identifySectionByMagic(u32 magic) const; // 802D7C00 + + protected: + struct INFEntry { + u32 stringOffset; + }; + const INFEntry *findINFForMessageID(int category, int message) const; // 802D7C90 + u32 getEntryFromMID(int index) const; // 802D7D70 + }; +} +namespace dScript { + class Res_c : public EGG::MsgRes { + public: + Res_c(const u8 *bmgFile, u32 unusedParam); // 800CE7F0 + ~Res_c(); + + u16 getCharScaleForMessageID(int category, int message) const; // 800CE890 + u8 getFontIDForMessageID(int category, int message) const; // 800CE8C0 + }; +} +class MessageClass { + public: + dDvdLoader_c loader; + void *rawBmgPointer; + dScript::Res_c *msgRes; +}; + +dScript::Res_c *GetBMG(); // 800CDD50 +void WriteBMGToTextBox(nw4r::lyt::TextBox *textBox, dScript::Res_c *res, int category, int message, int argCount, ...); // 0x800C9B50 + extern "C" dAc_Py_c* GetSpecificPlayerActor(int number); extern "C" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char rot, char layer); extern "C" dStageActor_c *Actor_SearchByID(u32 actorID); diff --git a/include/newer.h b/include/newer.h index 4f34f81..d98f290 100644 --- a/include/newer.h +++ b/include/newer.h @@ -27,5 +27,6 @@ enum NWRWorld { NWRWorld NewerWorldForLevelID(int world, int level); const wchar_t *NewerWorldName(NWRWorld world); +int getStarCoinCount(); #endif /* NEWER_H */ 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); diff --git a/src/newer.cpp b/src/newer.cpp index 6d672e2..2bad8a0 100644 --- a/src/newer.cpp +++ b/src/newer.cpp @@ -1,4 +1,5 @@ #include +#include NWRWorld NewerWorldForLevelID(int w, int l) { switch (w) { @@ -75,3 +76,23 @@ const wchar_t *NewerWorldName(NWRWorld world) { return L"Unknown World"; return NewerWorldNames[world]; } + + +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; +} -- 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 --- kamek_pal.x | 6 ++++++ src/koopatlas/hud.cpp | 48 +++++++++++++++++++++++++++++++++++++++++------- src/koopatlas/hud.h | 7 +++++++ 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/kamek_pal.x b/kamek_pal.x index 02bc004..4955575 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -734,6 +734,7 @@ SECTIONS { findTextBoxByName__Q23m2d17EmbedLayoutBase_cCFPCc = 0x80007320; findPictureByName__Q23m2d17EmbedLayoutBase_cCFPCc = 0x800073D0; findWindowByName__Q23m2d17EmbedLayoutBase_cCFPCc = 0x80007470; + __ct__Q23m2d13EmbedLayout_cFv = 0x800C89A0; __dt__Q23m2d13EmbedLayout_cFv = 0x800C89F0; loadArc__Q23m2d13EmbedLayout_cFPCcb = 0x800C8D00; @@ -745,9 +746,14 @@ SECTIONS { disableAllAnimations__Q23m2d13EmbedLayout_cFv = 0x800C95F0; isAnimOn__Q23m2d13EmbedLayout_cFi = 0x800C9700; isAnyAnimOn__Q23m2d13EmbedLayout_cFv = 0x800C9730; + setLangStrings__Q23m2d13EmbedLayout_cFPPCcPCiii = 0x800C9010; free__Q23m2d13EmbedLayout_cFv = 0x800C9A20; execAnimations__Q23m2d13EmbedLayout_cFv = 0x800C9650; + attachArc__Q23m2d8ResAcc_cFPvPCc = 0x801637A0; + + setSpeed__Q23m2d11FrameCtrl_cFf = 0x80163920; + scheduleForDrawing__Q23m2d6Base_cFv = 0x80163990; RenderEffects__Fii = 0x80093F10; 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 --- include/game.h | 69 ++++++++++++++++++++----- kamek_pal.x | 6 ++- src/koopatlas/hud.cpp | 122 ++++++++++++++++++++++++++++++++++++++++++++- src/koopatlas/hud.h | 18 ++++++- src/koopatlas/starcoin.cpp | 4 +- 5 files changed, 199 insertions(+), 20 deletions(-) diff --git a/include/game.h b/include/game.h index 7e8456d..2dc64a6 100755 --- a/include/game.h +++ b/include/game.h @@ -505,6 +505,20 @@ namespace lyt { class Group; class GroupContainer; + namespace detail { + class TexCoordAry { + public: + TexCoordAry(); + void Free(); + void Reserve(u8 count); + void SetSize(u8 count); + void Copy(const void *source, u8 count); + + u8 reservedSize, usedSize; + void *data; + }; + } + class Layout { public: Layout(); @@ -636,11 +650,17 @@ namespace lyt { u8 flag; char name[0x11]; - char userdata[8]; + char userdata[9]; - u8 _D5; u8 paneIsOwnedBySomeoneElse; u8 _D7; + + void SetVisible(bool value) { + if (value) + flag |= 1; + else + flag &= ~1; + } }; class TextBox : public Pane { @@ -657,7 +677,7 @@ namespace lyt { uchar GetVtxColorElement(ulong id) const; void SetVtxColorElement(ulong id, uchar value); - virtual void LoadMtx(const DrawInfo &info); + void LoadMtx(const DrawInfo &info); virtual void AllocStringBuffer(u16 size); virtual void FreeStringBuffer(); @@ -681,6 +701,26 @@ namespace lyt { u8 alignment; u8 flags; }; + + class Picture : public Pane { + public: + Picture(void *, void *); // todo: Picture((res::Picture const *,ResBlockSet const &)) + ~Picture(); + + void *GetRuntimeTypeInfo() const; + + void DrawSelf(const DrawInfo &info); + + ut::Color GetVtxColor(ulong id) const; + void SetVtxColor(ulong id, ut::Color color); + uchar GetVtxColorElement(ulong id) const; + void SetVtxColorElement(ulong id, uchar value); + + virtual void Append(const GXTexObj &obj); + + ut::Color colours[4]; + detail::TexCoordAry texCoords; + }; } @@ -2482,7 +2522,10 @@ namespace nw4r { void SetupGXWithColorMapping(Color c1, Color c2); public: - Color colors[8]; // todo: document + Color minColMapping, maxColMapping; + Color vtxColours[4]; + Color topColour, bottomColour; + u32 modeOfSomeKind; float scaleX; float scaleY; @@ -2517,12 +2560,12 @@ namespace nw4r { bool IsDrawFlagSet(ulong, ulong) const; - float _4C; + float widthLimit; float charSpace; - float somethingRelatedToLineHeight; - u32 _58; + float lineSpace; + u32 tabWidth; u32 drawFlag; - void *tagProcessorMaybe; + void *tagProcessor; }; } } @@ -2662,7 +2705,7 @@ namespace m2d { nw4r::lyt::Pane *getRootPane(); nw4r::lyt::Pane *findPaneByName(const char *name) const; nw4r::lyt::TextBox *findTextBoxByName(const char *name) const; - nw4r::lyt::Pane *findPictureByName(const char *name) const; // TODO: change to others + nw4r::lyt::Picture *findPictureByName(const char *name) const; nw4r::lyt::Pane *findWindowByName(const char *name) const; void animate(); @@ -2700,10 +2743,10 @@ namespace m2d { // does NSMBW even use consts? I have no idea. maybe not - void getPanes(const char **names, nw4r::lyt::Pane *output, int count) const; - void getWindows(const char **names, nw4r::lyt::Pane *output, int count) const; // TODO: change to others - void getPictures(const char **names, nw4r::lyt::Pane *output, int count) const; - void getTextBoxes(const char **names, nw4r::lyt::TextBox *output, int count) const; + void getPanes(const char **names, nw4r::lyt::Pane **output, int count) const; + void getWindows(const char **names, nw4r::lyt::Pane **output, int count) const; // TODO: change to others + void getPictures(const char **names, nw4r::lyt::Picture **output, int count) const; + void getTextBoxes(const char **names, nw4r::lyt::TextBox **output, int count) const; void setLangStrings(const char **names, const int *msgIDs, int category, int count); diff --git a/kamek_pal.x b/kamek_pal.x index 4955575..169d0b4 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -738,6 +738,11 @@ SECTIONS { __ct__Q23m2d13EmbedLayout_cFv = 0x800C89A0; __dt__Q23m2d13EmbedLayout_cFv = 0x800C89F0; loadArc__Q23m2d13EmbedLayout_cFPCcb = 0x800C8D00; + getPanes__Q23m2d13EmbedLayout_cCFPPCcPPQ34nw4r3lyt4Panei = 0x800C8E50; + getWindows__Q23m2d13EmbedLayout_cCFPPCcPPQ34nw4r3lyt6Windowi = 0x800C8EC0; + getPictures__Q23m2d13EmbedLayout_cCFPPCcPPQ34nw4r3lyt7Picturei = 0x800C8F30; + getTextBoxes__Q23m2d13EmbedLayout_cCFPPCcPPQ34nw4r3lyt7TextBoxi = 0x800C8FA0; + setLangStrings__Q23m2d13EmbedLayout_cFPPCcPCiii = 0x800C9010; loadAnimations__Q23m2d13EmbedLayout_cFPPCci = 0x800C90A0; loadGroups__Q23m2d13EmbedLayout_cFPPCcPii = 0x800C91E0; enableNonLoopAnim__Q23m2d13EmbedLayout_cFib = 0x800C93E0; @@ -746,7 +751,6 @@ SECTIONS { disableAllAnimations__Q23m2d13EmbedLayout_cFv = 0x800C95F0; isAnimOn__Q23m2d13EmbedLayout_cFi = 0x800C9700; isAnyAnimOn__Q23m2d13EmbedLayout_cFv = 0x800C9730; - setLangStrings__Q23m2d13EmbedLayout_cFPPCcPCiii = 0x800C9010; free__Q23m2d13EmbedLayout_cFv = 0x800C9A20; execAnimations__Q23m2d13EmbedLayout_cFv = 0x800C9650; 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(-) 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(+) 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(-) 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 --- kamek_pal.x | 1 + src/koopatlas/hud.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++------ src/koopatlas/hud.h | 25 +++++++++++++++------- 3 files changed, 71 insertions(+), 13 deletions(-) diff --git a/kamek_pal.x b/kamek_pal.x index 5f11ac5..80ad1ce 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -17,6 +17,7 @@ SECTIONS { RealAcPyDtor = 0x80144820; InsertIntIntoTextBox1 = 0x800B3BE0; + WriteNumberToTextBox__FPiPCiPQ34nw4r3lyt7TextBoxb = 0x800B3B60; __ct__20daJrClownForPlayer_cFv = 0x80810480; __dt__20daJrClownForPlayer_cFv = 0x80810540; /* Beans indeed. */ 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 --- include/game.h | 85 +++++++++++++++++++++++++++++++++++++++++++++++---- kamek_pal.x | 6 +++- src/koopatlas/hud.cpp | 18 +++++++++++ src/koopatlas/hud.h | 4 ++- src/palaceDude.cpp | 2 +- src/replay.S | 6 ++-- src/switchblock.S | 6 ++-- 7 files changed, 112 insertions(+), 15 deletions(-) diff --git a/include/game.h b/include/game.h index 7911880..e31e675 100755 --- a/include/game.h +++ b/include/game.h @@ -80,9 +80,60 @@ struct StartLevelInfo { unsigned char level2; // 0x0F }; -extern void *GameMgr; +class GMgr8 { + public: + virtual ~GMgr8(); + + int _4; + float _8, _C; + u32 _10, _14; + u8 _18, _19, _1A, _1B, _1C; + u32 _20, _24, _28, _2C, _30; +}; + +struct GMgrA0 { + u32 _0, _4, _8; + u8 _C; +}; + +class GameMgr { + public: + virtual ~GameMgr(); + + u32 _4; + GMgr8 eight; + u32 _3C, _40, _44, _48, _4C, _50, _54, _58; + u32 _5C, _60, _64, _68, _6C; + u32 _70[10]; + u8 _98; + u32 _9C; + GMgrA0 _A0[40]; + u32 _320[10], _348[10]; + u32 _370, _374, _378, _37C; + u8 switchPalaceFlag; + u32 CharIDs[4]; + u8 _394; + u8 _395[10]; + u8 _39F[10]; + u8 _3A9[10]; + u8 _3B3; + u32 numberToInsertInThing[7]; + u32 msgCategory, msgID; + u8 _3D8; + u8 currentControllerType, layoutShadowFlag; + u32 numberToInsertInThing10, numberToInsertInThing11; + u32 _3E4, _3E8, _3EC, _3F0, _3F4, _3F8; + // unmapped data from 3FC..AEC (0x6F0) + u8 _3FC[0x6F0]; + u32 _AEC, _AF0, _AF4, _AF8; + u8 _AFC, _AFD, _AFE[88]; + u8 _B56[4]; + u8 _B5A, _B5B; +}; + +extern GameMgr *GameMgrP; inline void *GetGameMgr() { - return GameMgr; + return GameMgrP; } bool QueryPlayerAvailability(int id); @@ -219,9 +270,31 @@ inline SaveHandler *GetSaveHandler() { #define WPAD_MINUS 0x1000 #define WPAD_HOME 0x8000 +struct Remocon { + virtual ~Remocon(); + int id; + int controllerType; + u32 untouchedButtons; + u32 lastUntouchedButtons; + u32 heldButtons; + u32 lastHeldButtons; + u32 nowPressed; + u32 _20, _24, _28, _2C, _30; + Vec acc, lastAcc; + Vec2 accVertical, lastAccVertical; + Vec2 vec_5C, lastVec_5C; + Vec2 vec_6C; + Vec2 vec_74, lastVec_74; + float wiimoteMoveDistanceOrSomething; + float lastWiimoteMoveDistanceOrSomething; + u8 isShaking, _8D; + u16 tiltAmount; + u8 _90, _91, _92; +}; + struct RemoconMngClass { void *vtable; - void *controllers[4]; + Remocon *controllers[4]; }; /* @@ -246,7 +319,7 @@ inline int GetActiveWiimoteID() { return ActiveWiimoteID; } -inline void *GetActiveRemocon() { +inline Remocon *GetActiveRemocon() { return GetRemoconMng()->controllers[GetActiveWiimoteID()]; } @@ -254,11 +327,11 @@ inline void *GetActiveWiimote() { return ActiveWiimote; } -inline unsigned int Remocon_GetButtons(void *self) { +inline unsigned int Remocon_GetButtons(Remocon *self) { return *((unsigned int*)((u32)self+0x18)); } -inline unsigned int Remocon_GetPressed(void *self) { +inline unsigned int Remocon_GetPressed(Remocon *self) { return *((unsigned int*)((u32)self+0x1C)); } diff --git a/kamek_pal.x b/kamek_pal.x index 80ad1ce..75613ad 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -11,6 +11,10 @@ SECTIONS { __dt__18BGGMEffectRendererFv = 0x80092E30; __vt__18BGGMEffectRenderer = 0x80311908; __construct_array = 0x802DCC90; + + GetBMG__Fv = 0x800CDD50; + WriteBMGToTextBox__FPQ34nw4r3lyt7TextBoxPQ27dScript5Res_ciiie = 0x800C9B50; + m2d__Anm_c__Load = 0x801644F0; m2d__AnmResHandler_c__Load = 0x80163FA0; @@ -979,7 +983,7 @@ SECTIONS { ArchiveHeap = 0x8042A72C; DVDClass = 0x8042A318; - GameMgr = 0x8042A25C; + GameMgrP = 0x8042A25C; SaveFileInstance = 0x8042A320; SaveHandlerInstance = 0x8042A298; RemoconMng = 0x8042A230; 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]; diff --git a/src/palaceDude.cpp b/src/palaceDude.cpp index 6a8d7ff..8eb4a99 100644 --- a/src/palaceDude.cpp +++ b/src/palaceDude.cpp @@ -29,7 +29,7 @@ int dPalaceDude_c::onExecute() { dMsgBoxManager_c::instance->showMessage(settings & 0xFFFFFFF); SaveBlock *save = GetSaveFile()->GetBlock(-1); - *((u8*)(((u32)GameMgr)+0x380)) |= (1 << (settings >> 28)); + GameMgrP->switchPalaceFlag|= (1 << (settings >> 28)); } } diff --git a/src/replay.S b/src/replay.S index 8c3f6c7..89868cf 100644 --- a/src/replay.S +++ b/src/replay.S @@ -27,7 +27,7 @@ .extern EGG__Heap__free__FPvPv .extern GameHeap2 .extern EggControllerClassPtrMaybe -.extern GameMgr +.extern GameMgrP .extern StrangeReplayValue1 .extern StrangeReplayValue2 .extern StrangeReplayValue3 @@ -192,8 +192,8 @@ replayStartLoop: lwzx r3, r3, r6 stw r3, 0x18(r4) - lis r3, GameMgr@h - ori r3, r3, GameMgr@l + lis r3, GameMgrP@h + ori r3, r3, GameMgrP@l lwz r3, 0(r3) lbz r3, 0x380(r3) stb r3, 0x21(r4) diff --git a/src/switchblock.S b/src/switchblock.S index b86d5e2..4df2433 100644 --- a/src/switchblock.S +++ b/src/switchblock.S @@ -11,14 +11,14 @@ #endif .align 4 -.extern GameMgr +.extern GameMgrP .extern BG_GM_ptr .extern _restgpr_27 .global BG_GM_InitRedSwitchFlag_Patch BG_GM_InitRedSwitchFlag_Patch: - lis r5, GameMgr@h - ori r5, r5, GameMgr@l + lis r5, GameMgrP@h + ori r5, r5, GameMgrP@l lwz r5, 0(r5) addis r4, r3, 9 -- cgit v1.2.3 From 014f3668eb47b1576bdc182b1db00417f9938cf1 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 00:51:43 +0200 Subject: added untested support for world change nodes --- include/game.h | 9 +++++++- src/koopatlas/hud.cpp | 50 ++++++++++++++++++++++++++++++++++++------- src/koopatlas/hud.h | 9 ++++++-- src/koopatlas/mapdata.cpp | 16 ++++++++++++++ src/koopatlas/mapdata.h | 17 ++++++++++++++- src/koopatlas/pathmanager.cpp | 32 +++++++++++++++++++++++++-- 6 files changed, 119 insertions(+), 14 deletions(-) diff --git a/include/game.h b/include/game.h index e31e675..41b925f 100755 --- a/include/game.h +++ b/include/game.h @@ -26,6 +26,7 @@ extern "C" { int wcslen(const wchar_t *str); int strlen(const char *str); char *strcpy(char *dest, const char *src); +char *strncpy(char *dest, const char *src, int num); int strncmp(const char *str1, const char *str2, int num); float atan(float x); @@ -200,7 +201,13 @@ public: struct { // ALL Newer additions should go here // This array has been verified as safe to replace - u8 currentNewerWorld; // 0x6FC + char newerWorldName[36]; // 0x6FC + GXColor fsTextColours[2]; // 0x720 + GXColor fsHintColours[2]; // 0x728 + GXColor hudTextColours[2]; // 0x730 + s16 hudHintH, hudHintS, hudHintL; // 0x738 + u8 currentMapMusic; // 0x73E + u8 _padding; // 0x73F }; }; u8 toad_location[10]; // 0x742 diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index c9124d2..4f4ce2f 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -84,6 +84,9 @@ int dWMHud_c::onCreate() { layoutLoaded = true; willShowHeader = false; + willShowFooter = false; + + loadFooterInfo(); if (!dScKoopatlas_c::instance->pathManager.isMoving) enteredNode(); @@ -110,7 +113,13 @@ int dWMHud_c::onExecute() { if (willShowHeader && (!(layout.isAnimOn(SHOW_HEADER)))) { willShowHeader = false; loadHeaderInfo(); - playShowHeaderAnim(); + playShowAnim(SHOW_HEADER); + } + + if (willShowFooter && (!(layout.isAnimOn(SHOW_FOOTER)))) { + willShowFooter = false; + loadFooterInfo(); + playShowAnim(SHOW_FOOTER); } updatePressableButtonThingies(); @@ -134,19 +143,19 @@ int dWMHud_c::onDraw() { -void dWMHud_c::playShowHeaderAnim() { +void dWMHud_c::playShowAnim(int id) { if (!this || !this->layoutLoaded) return; - layout.enableNonLoopAnim(SHOW_HEADER); + layout.enableNonLoopAnim(id); } -void dWMHud_c::playHideHeaderAnim() { +void dWMHud_c::playHideAnim(int id) { if (!this || !this->layoutLoaded) return; - if (!layout.isAnimOn(SHOW_HEADER)) { - layout.enableNonLoopAnim(SHOW_HEADER, true); + if (!layout.isAnimOn(id)) { + layout.enableNonLoopAnim(id, true); } - layout.grpHandlers[SHOW_HEADER].frameCtrl.flags = 3; // NO_LOOP | REVERSE + layout.grpHandlers[id].frameCtrl.flags = 3; // NO_LOOP | REVERSE } @@ -222,6 +231,26 @@ void dWMHud_c::loadHeaderInfo() { } +void dWMHud_c::loadFooterInfo() { + SaveBlock *save = GetSaveFile()->GetBlock(-1); + + wchar_t convertedWorldName[36]; + int i; + for (i = 0; i < 36; i++) { + convertedWorldName[i] = save->newerWorldName[i]; + if (convertedWorldName[i] == 0) + break; + } + convertedWorldName[35] = 0; + + WorldName->SetString(convertedWorldName); + WorldNameS->SetString(convertedWorldName); + + WorldName->colour1 = save->hudTextColour[0]; + WorldName->colour2 = save->hudTextColour[1]; +} + + void dWMHud_c::enteredNode(dKPNode_s *node) { if (node == 0) @@ -240,12 +269,17 @@ void dWMHud_c::leftNode() { if ((layout.isAnimOn(SHOW_HEADER) && (layout.grpHandlers[SHOW_HEADER].frameCtrl.flags & 2)) || (!layout.isAnimOn(SHOW_HEADER))) { // currently being shown, OR fully shown already - playHideHeaderAnim(); + playHideAnim(SHOW_HEADER); } } } +void dWMHud_c::hideAndShowFooter() { + willShowFooter = true; + playHideAnim(SHOW_FOOTER); +} + void dWMHud_c::setupLives() { static const int LogicalPlayerIDs[] = {0,1,3,2}; diff --git a/src/koopatlas/hud.h b/src/koopatlas/hud.h index e507aea..deac84f 100644 --- a/src/koopatlas/hud.h +++ b/src/koopatlas/hud.h @@ -21,11 +21,13 @@ class dWMHud_c : public dBase_c { void enteredNode(dKPNode_s *node = 0); void leftNode(); + void hideAndShowFooter(); + void setupLives(); private: - void playShowHeaderAnim(); - void playHideHeaderAnim(); + void playShowAnim(int id); + void playHideAnim(int id); void loadHeaderInfo(); bool willShowHeader; @@ -34,6 +36,9 @@ class dWMHud_c : public dBase_c { int displayedControllerType; void updatePressableButtonThingies(); + void loadFooterInfo(); + bool willShowFooter; + nw4r::lyt::Pane *N_IconPosXP_00[4]; diff --git a/src/koopatlas/mapdata.cpp b/src/koopatlas/mapdata.cpp index 52a7937..29c6a23 100644 --- a/src/koopatlas/mapdata.cpp +++ b/src/koopatlas/mapdata.cpp @@ -205,6 +205,12 @@ void dKPMapData_c::fixup() { fixRef(data->unlockData); fixRef(data->sectors); fixRef(data->backgroundName); + if (data->version >= 2) { + fixRef(data->worlds); + for (int i = 0; i < data->worldCount; i++) { + fixRef(data->worlds[i].name); + } + } for (int iLayer = 0; iLayer < data->layerCount; iLayer++) { dKPLayer_s *layer = fixRef(data->layers[iLayer]); @@ -280,6 +286,16 @@ void dKPMapData_c::fixup() { } +const dKPWorldDef_s *dKPMapData_c::findWorldDef(int id) { + for (int i = 0; i < data->worldCount; i++) { + if (data->worlds[i].key == id) + return &data->worlds[i]; + } + + return 0; +} + + /****************************************************************************** * Generic Layer ******************************************************************************/ diff --git a/src/koopatlas/mapdata.h b/src/koopatlas/mapdata.h index bc0c599..f7194ef 100644 --- a/src/koopatlas/mapdata.h +++ b/src/koopatlas/mapdata.h @@ -53,7 +53,7 @@ struct dKPPath_s; struct dKPNode_s { enum NodeTypes { - PASS_THROUGH, STOP, LEVEL, CHANGE + PASS_THROUGH, STOP, LEVEL, CHANGE, WORLD_CHANGE }; short x, y; @@ -79,6 +79,7 @@ struct dKPNode_s { union { struct { u8 levelNumber[2]; bool hasSecret; }; struct { const char *destMap; u8 thisID, foreignID, transition, _; }; + struct { u8 worldID, __[3]; }; }; dKPPath_s *getAnyExit() { @@ -187,6 +188,15 @@ struct dKPLayer_s { int findNodeID(dKPNode_s *node); }; +struct dKPWorldDef_s { + const char *name; + GXColor fsTextColours[2]; + GXColor fsHintColours[2]; + GXColor hudTextColours[2]; + s16 hudHintH, hudHintS, hudHintL; + u8 key, trackID; +}; + struct dKPMapFile_s { u32 magic; int version; @@ -202,6 +212,9 @@ struct dKPMapFile_s { dKPLayer_s::sector_s *sectors; const char *backgroundName; + + dKPWorldDef_s *worlds; + int worldCount; }; class dKPMapData_c { @@ -253,6 +266,8 @@ class dKPMapData_c { dKPNodeExtra_c *levelNodeExtraArray; + const dKPWorldDef_s *findWorldDef(int id) const; + dKPMapData_c(); bool load(const char *filename); ~dKPMapData_c(); diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index e42246e..2401e04 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -573,8 +573,8 @@ void dWMPathManager_c::moveThroughPath() { if (to->type == dKPNode_s::LEVEL) { // Always stop on levels reallyStop = true; - } else if (to->type == dKPNode_s::CHANGE) { - // Never stop on entrances + } else if (to->type == dKPNode_s::CHANGE || to->type == dKPNode_s::WORLD_CHANGE) { + // Never stop on entrances or on world changes reallyStop = false; } else if (to->type == dKPNode_s::PASS_THROUGH) { // If there's only one exit here, then stop even though @@ -590,6 +590,34 @@ void dWMPathManager_c::moveThroughPath() { reallyStop = true; } + if (to->type == dKPNode_s::WORLD_CHANGE) { + // Set the current world info + SaveBlock *save = GetSaveFile()->GetBlock(-1); + + OSReport("Activating world change %d\n", to->worldID); + dKPWorldDef_s *world = dScKoopatlas_c::instance->mapData.findWorldDef(to->worldID); + if (world) { + OSReport("Found!\n"); + strncpy(save->newerWorldName, world->name, 36); + save->newerWorldName[35] = 0; + save->currentMapMusic = world->trackID; + + for (int i = 0; i < 2; i++) { + save->fsTextColours[i] = world->fsTextColours[i]; + save->fsHintColours[i] = world->fsHintColours[i]; + save->hudTextColours[i] = world->hudTextColours[i]; + } + + save->hudHintH = world->hudHintH; + save->hudHintS = world->hudHintS; + save->hudHintL = world->hudHintL; + + dWMHud_c::instance->hideAndShowFooter(); + } else { + OSReport("Not found!\n"); + } + } + if (to->type == dKPNode_s::CHANGE) { // Go to another map -- cgit v1.2.3 From 411c5a8e210b5cbca330a5438e2406dbe1ffecab Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 04:40:34 +0200 Subject: made world changes work, and HUD colourising and other fun things --- include/game.h | 36 +++++++++- include/newer.h | 26 ------- src/fileselect.S | 59 ++++++++++------ src/koopatlas/hud.cpp | 158 ++++++++++++++++++++++++++++++++++++++++-- src/koopatlas/hud.h | 21 +++++- src/koopatlas/mapdata.cpp | 2 +- src/koopatlas/pathmanager.cpp | 11 +-- src/newer.cpp | 76 -------------------- 8 files changed, 250 insertions(+), 139 deletions(-) diff --git a/include/game.h b/include/game.h index 41b925f..32b3a1d 100755 --- a/include/game.h +++ b/include/game.h @@ -560,7 +560,13 @@ namespace ut { LinkListNode initialNode; }; - class Color : public GXColor { }; + class Color : public GXColor { + public: + GXColor& operator=(const GXColor &other) { + *((u32*)this) = *((u32*)&other); + return *this; + } + }; class Rect { public: @@ -651,9 +657,35 @@ namespace lyt { }; + class TexMap { + public: + void *image, *palette; + u16 width, height; + f32 minLOD, magLOD; + u16 lodBias, palEntryNum; + struct + { + u32 textureFormat: 4; + u32 mipmap: 1; + u32 wrapS: 2; + u32 wrapT: 2; + u32 minFilter: 3; + u32 magFilter: 1; + u32 biasClampEnable: 1; + u32 edgeLODEnable: 1; + u32 anisotropy: 2; + u32 paletteFormat: 2; + } mBits; + }; + class Material { public: - // ... + virtual ~Material(); + + // cheating a bit here + u8 _[0x3C]; + // this is actually a pointer to more stuff, not just texmaps + TexMap *texMaps; }; class Pane { diff --git a/include/newer.h b/include/newer.h index d98f290..cf21cbb 100644 --- a/include/newer.h +++ b/include/newer.h @@ -1,32 +1,6 @@ #ifndef NEWER_H #define NEWER_H -enum NWRWorld { - ISLAND = 0, YOSHI_ISLAND = 0, - DESERT = 1, RUBBLE_RUINS = 1, - SEWER = 2, SOGGY_SEWERS = 2, - MOUNTAIN = 3, MUSHROOM_PEAKS = 3, - SAKURA = 4, SAKURA_VILLAGE = 4, - FREEZEFLAME = 5, FREEZEFLAME_GLACIER = 5, - VOLCANO = 6, FREEZEFLAME_VOLCANO = 6, - PUMPKIN = 7, PUMPKIN_BONEYARD = 7, - SKY_MOUNTAIN = 8, - SKY = 9, STARRY_SKIES = 9, - PLANET = 10, KOOPA_PLANET = 10, - CORE = 11, KOOPA_CORE = 11, - BONUS_LAND = 12, - GOLDWOOD = 13, GOLDWOOD_FOREST = 13, - MINIMEGA = 14, MINIMEGA_ISLAND = 14, - CRYSTAL = 15, CRYSTAL_CAVES = 15, - BOMBARD = 16, BOMBARD_CLIFFS = 16, - SKY_CITY = 17, - WORLD_COUNT = 18, - UNKNOWN_WORLD = 255 -}; - -NWRWorld NewerWorldForLevelID(int world, int level); - -const wchar_t *NewerWorldName(NWRWorld world); int getStarCoinCount(); #endif /* NEWER_H */ diff --git a/src/fileselect.S b/src/fileselect.S index 9f7f396..16a1047 100644 --- a/src/fileselect.S +++ b/src/fileselect.S @@ -54,8 +54,7 @@ DFNiceTitle: bctr .extern findTextBoxByName__Q23m2d17EmbedLayoutBase_cCFPCc -.extern NewerWorldNames -.extern NewerWorldCount +.extern findPictureByName__Q23m2d17EmbedLayoutBase_cCFPCc .extern InsertIntIntoTextBox1 .global DFNiceWorldName DFNiceWorldName: @@ -71,22 +70,21 @@ DFNiceWorldName: stw r25, 0x14(r1) mr r20, r4 - # get Newer map number - lbz r6, 0x6FC(r31) - lis r8, NewerWorldCount@h - ori r8, r8, NewerWorldCount@l - lwz r8, 0(r8) - cmpw r6, r8 - bge invalidThing - slwi r6, r6, 2 - lis r7, NewerWorldNames@h - ori r7, r7, NewerWorldNames@l - lwzx r4, r7, r6 - b gotName -invalidThing: - lis r4, InvalidWorld@h - ori r4, r4, InvalidWorld@l -gotName: + # Savefile is in r31 + # World Name field is in r20 + + lis r4, ConvertedWorldName@h + ori r4, r4, ConvertedWorldName@l + mr r3, r4 + mr r5, r31 + li r6, 36 + mtctr r6 +convWNameLoop: + lbz r6, 0x6FC(r5) + sth r6, 0(r3) + addi r3, r3, 2 + addi r5, r5, 1 + bdnz convWNameLoop mr r3, r20 li r5, 0 @@ -95,6 +93,24 @@ gotName: mtctr r12 bctrl + # now set the colours + # Text colours: 0x720, hint colours: 0x728 + lwz r3, 0x720(r31) + stw r3, 0xDC(r20) + lwz r3, 0x724(r31) + stw r3, 0xE0(r20) + + addi r3, r30, 0x74 + lis r4, Picture_00@h + ori r4, r4, Picture_00@l + bl findPictureByName__Q23m2d17EmbedLayoutBase_cCFPCc + lwz r4, 0x728(r31) + stw r4, 0xD8(r3) + stw r4, 0xDC(r3) + lwz r4, 0x72C(r31) + stw r4, 0xE0(r3) + stw r4, 0xE4(r3) + # While we're at it, take care of some other things # r21 shall hold our star coin count; r22 shall hold our exit count # r23 shall hold the level pointer @@ -255,10 +271,13 @@ NormalExitStr: .string " %d-%d\n" SecretExitStr: .string " %d-%d\n" StarCoinCount: .string "StarCoinCount" ExitCount: .string "ExitCount" +Picture_00: .string "Picture_00" .align 4 DFTitle: .short 'F','i','l','e',' ','X',0 -InvalidWorld: -.short '<','I','n','v','a','l','i','d',' ','W','o','r','l','d','>',0 +ConvertedWorldName: +.short 0,0,0,0,0,0,0,0,0,0,0,0 # 12 +.short 0,0,0,0,0,0,0,0,0,0,0,0 # 12 +.short 0,0,0,0,0,0,0,0,0,0,0,0 # 12 diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index 4f4ce2f..84329bf 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -1,5 +1,146 @@ #include "koopatlas/hud.h" + +dTexMapColouriser_c::dTexMapColouriser_c() { + texmap = 0; + original = 0; + mine = 0; +} + +void *EGG__Heap__alloc(unsigned long size, int unk, void *heap); +void EGG__Heap__free(void *ptr, void *heap); + +dTexMapColouriser_c::~dTexMapColouriser_c() { + resetAndClear(); +} + +void dTexMapColouriser_c::resetAndClear() { + texmap = 0; + if (mine) { + EGG__Heap__free(mine, 0); + mine = 0; + } +} + +void dTexMapColouriser_c::setTexMap(nw4r::lyt::TexMap *tm) { + OSReport("Colourising TexMap: %p (w:%d h:%d)\n", tm, tm->width, tm->height); + if (texmap) + resetAndClear(); + + if (tm->mBits.textureFormat != GX_TF_IA8) { + OSReport("Warning: Trying to colourise image whose format is %d not GX_TF_IA8\n", tm->mBits.textureFormat); + } + + texmap = tm; + original = (u16*)tm->image; + mine = (u16*)EGG__Heap__alloc(tm->width * tm->height * 4, 0x20, mHeap::gameHeaps[2]); + tm->image = mine; + tm->mBits.textureFormat = GX_TF_RGBA8; +} + +void dTexMapColouriser_c::applyAlso(nw4r::lyt::TexMap *tm) { + if (!texmap) { + setTexMap(tm); + } else { + tm->image = mine; + tm->mBits.textureFormat = GX_TF_RGBA8; + } +} + +inline static float hslValue(float n1, float n2, float hue) { + if (hue > 6.0f) + hue -= 6.0f; + else if (hue < 0.0f) + hue += 6.0f; + + if (hue < 1.0f) + return n1 + (n1 - n1) * hue; + else if (hue < 3.0f) + return n2; + else if (hue < 4.0f) + return n1 + (n2 - n1) * (4.0f - hue); + else + return n1; +} + +void dTexMapColouriser_c::colourise(int h, int s, int l) { + if (!mine) + return; + + int width = texmap->width, height = texmap->height; + int texelW = width / 4, texelH = height / 4; + + u16 *source = original, *dest = mine; + + float hueParam = h / 360.0f; + float satParam = s / 100.0f; + float lumParam = l / 100.0f; + + for (int texelY = 0; texelY < texelH; texelY++) { + for (int texelX = 0; texelX < texelW; texelX++) { + for (int y = 0; y < 4; y++) { + for (int x = 0; x < 4; x++) { + u8 intensity = *source & 0xFF; + u8 alpha = *source >> 8; + + u8 r, g, b; + + // This is a hack + if (alpha < 250) { + r = g = b = intensity; + } else { + // converting from GIMP's colourise code... + // h and s are always the same + // l is the only thing we need to touch: + // we get the luminance from the source pixel + // (which, conveniently, is the intensity) + // manipulate it using the passed l and then + // convert the whole thing to RGB + + float lum = intensity / 255.0f; + + // manipulate it + if (l > 0) { + lum = lum * (1.0f - lumParam); + lum += (1.0f - (1.0f - lumParam)); + } else if (l < 0) { + lum = lum * (lumParam + 1.0f); + } + + // make it RGB + + if (s == 0) { + r = g = b = lum*255.0f; + } else { + float m1, m2; + if (lum <= 0.5f) + m2 = lum * (1.0f + satParam); + else + m2 = lum + satParam - lum * satParam; + + m1 = 2.0f * lum - m2; + + r = hslValue(m1, m2, hueParam * 6.0f + 2.0) * 255.0f; + g = hslValue(m1, m2, hueParam * 6.0f) * 255.0f; + b = hslValue(m1, m2, hueParam * 6.0f - 2.0) * 255.0f; + } + } + + // now write it + dest[0] = (alpha<<8)|r; + dest[16] = (g<<8)|b; + + source++; + dest++; + } + } + + dest += 16; + } + } +} + + dWMHud_c *dWMHud_c::instance = 0; dWMHud_c *dWMHud_c::build() { @@ -63,13 +204,13 @@ int dWMHud_c::onCreate() { layout.getPanes(paneNames, &N_IconPosXP_00[0], 4); static const char *pictureNames[] = { - "Header_Centre", "Header_Right", + "Header_Centre", "Header_Right", "Footer", "NormalExitFlag", "SecretExitFlag", "StarCoinOn0", "StarCoinOn1", "StarCoinOn2", "P_marioFace_00", "P_luigiFace_00", "P_BkinoFace_00", "P_YkinoFace_00" }; - layout.getPictures(pictureNames, &Header_Centre, 11); + layout.getPictures(pictureNames, &Header_Centre, 12); static const char *textBoxNames[] = { "LevelName", "LevelNameS", @@ -81,6 +222,10 @@ int dWMHud_c::onCreate() { }; layout.getTextBoxes(textBoxNames, &LevelName, 11); + headerCol.setTexMap(Header_Right->material->texMaps); + headerCol.applyAlso(Header_Centre->material->texMaps); + footerCol.setTexMap(Footer->material->texMaps); + layoutLoaded = true; willShowHeader = false; @@ -228,6 +373,9 @@ void dWMHud_c::loadHeaderInfo() { totalWidth = 270.0f; Header_Centre->size.x = totalWidth; Header_Right->trans.x = totalWidth; + + SaveBlock *save = GetSaveFile()->GetBlock(-1); + headerCol.colourise(save->hudHintH, save->hudHintS, save->hudHintL); } @@ -246,8 +394,10 @@ void dWMHud_c::loadFooterInfo() { WorldName->SetString(convertedWorldName); WorldNameS->SetString(convertedWorldName); - WorldName->colour1 = save->hudTextColour[0]; - WorldName->colour2 = save->hudTextColour[1]; + WorldName->colour1 = save->hudTextColours[0]; + WorldName->colour2 = save->hudTextColours[1]; + + footerCol.colourise(save->hudHintH, save->hudHintS, save->hudHintL); } diff --git a/src/koopatlas/hud.h b/src/koopatlas/hud.h index deac84f..c0079af 100644 --- a/src/koopatlas/hud.h +++ b/src/koopatlas/hud.h @@ -3,6 +3,23 @@ #include "koopatlas/core.h" +// Colourises an IA8 texture +class dTexMapColouriser_c { + public: + dTexMapColouriser_c(); + ~dTexMapColouriser_c(); + + void resetAndClear(); + void setTexMap(nw4r::lyt::TexMap *tm); + void applyAlso(nw4r::lyt::TexMap *tm); + void colourise(int h, int s, int l); + + private: + nw4r::lyt::TexMap *texmap; + u16 *original; + u16 *mine; +}; + class dWMHud_c : public dBase_c { public: dWMHud_c(); @@ -39,12 +56,14 @@ class dWMHud_c : public dBase_c { void loadFooterInfo(); bool willShowFooter; + dTexMapColouriser_c headerCol, footerCol; + nw4r::lyt::Pane *N_IconPosXP_00[4]; nw4r::lyt::Picture - *Header_Centre, *Header_Right, + *Header_Centre, *Header_Right, *Footer, *NormalExitFlag, *SecretExitFlag, *StarCoinOn[3], *P_marioFace_00, *P_luigiFace_00, diff --git a/src/koopatlas/mapdata.cpp b/src/koopatlas/mapdata.cpp index 29c6a23..d4f9d0c 100644 --- a/src/koopatlas/mapdata.cpp +++ b/src/koopatlas/mapdata.cpp @@ -286,7 +286,7 @@ void dKPMapData_c::fixup() { } -const dKPWorldDef_s *dKPMapData_c::findWorldDef(int id) { +const dKPWorldDef_s *dKPMapData_c::findWorldDef(int id) const { for (int i = 0; i < data->worldCount; i++) { if (data->worlds[i].key == id) return &data->worlds[i]; diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 2401e04..896707a 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -566,7 +566,7 @@ void dWMPathManager_c::moveThroughPath() { isJumping = false; timer = 0.0; - SpammyReport("reached path end (%p)\n", to); + SpammyReport("reached path end (%p) with type %d\n", to, to->type); bool reallyStop = false; @@ -595,7 +595,7 @@ void dWMPathManager_c::moveThroughPath() { SaveBlock *save = GetSaveFile()->GetBlock(-1); OSReport("Activating world change %d\n", to->worldID); - dKPWorldDef_s *world = dScKoopatlas_c::instance->mapData.findWorldDef(to->worldID); + const dKPWorldDef_s *world = dScKoopatlas_c::instance->mapData.findWorldDef(to->worldID); if (world) { OSReport("Found!\n"); strncpy(save->newerWorldName, world->name, 36); @@ -653,13 +653,6 @@ void dWMPathManager_c::moveThroughPath() { 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]); - if (nWorld != UNKNOWN_WORLD) { - save->currentNewerWorld = (u8)nWorld; - } - } } else { startMovementTo(to->getOppositeAvailableExitTo(currentPath)); SpammyReport("passthrough node, continuing to next path\n"); diff --git a/src/newer.cpp b/src/newer.cpp index 2bad8a0..0b53fa6 100644 --- a/src/newer.cpp +++ b/src/newer.cpp @@ -1,82 +1,6 @@ #include #include -NWRWorld NewerWorldForLevelID(int w, int l) { - switch (w) { - case 1: return YOSHI_ISLAND; - case 2: - if (((l>1) && (l<5)) || (l==15) || (l==33) || (l==34)) - return SOGGY_SEWERS; - else - return RUBBLE_RUINS; - case 3: return MUSHROOM_PEAKS; - case 4: return SAKURA_VILLAGE; - case 5: - if (l<7 || l==15 || l==33 || l==34) - return FREEZEFLAME_GLACIER; - else - return FREEZEFLAME_VOLCANO; - case 6: return PUMPKIN_BONEYARD; - case 7: - if (l<4) - return SKY_MOUNTAIN; - else - return STARRY_SKIES; - case 8: - if (l<6 || l==15 || l==25 || l==33 || l==34) - return KOOPA_PLANET; - else - return KOOPA_CORE; - case 9: return BONUS_LAND; - case 10: - if (l<6 || l==30 || l==41) - return GOLDWOOD_FOREST; - else if (l<11 || l==32) - return MINIMEGA_ISLAND; - else if (l<16 || l==33 || l==34 || l==31) - return CRYSTAL_CAVES; - else if (l<19) - return BOMBARD_CLIFFS; - else - return SKY_CITY; - } - - return UNKNOWN_WORLD; -} - - -const wchar_t *NewerWorldNames[] = { - L"Yoshi's Island", - L"Rubble Ruins", - L"Soggy Sewers", - L"Mushroom Peaks", - L"Sakura Village", - L"Freezeflame Glacier", - L"Freezeflame Volcano", - L"Pumpkin Boneyard", - L"Sky Mountain", - L"Starry Skies", - L"Koopa Planet", - L"Koopa Core", - L"Bonus Land", - L"Goldwood Forest", - L"Mini-Mega Island", - L"Crystal Caves", - L"Bombard Cliffs", - L"Sky City" -}; - -// This is an array so it can be accessed from fileselect.S -int NewerWorldCount[] = { - 18 -}; - -const wchar_t *NewerWorldName(NWRWorld world) { - if (world < 0 || world >= WORLD_COUNT) - return L"Unknown World"; - return NewerWorldNames[world]; -} - int getStarCoinCount() { SaveBlock *save = GetSaveFile()->GetBlock(-1); -- cgit v1.2.3 From e30d836af369f251f83375dd9a9dbab435ee61f1 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 05:25:01 +0200 Subject: world change nodes now don't activate if you're already at that world --- src/koopatlas/pathmanager.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 896707a..97d9265 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -597,22 +597,26 @@ void dWMPathManager_c::moveThroughPath() { OSReport("Activating world change %d\n", to->worldID); const dKPWorldDef_s *world = dScKoopatlas_c::instance->mapData.findWorldDef(to->worldID); if (world) { - OSReport("Found!\n"); - strncpy(save->newerWorldName, world->name, 36); - save->newerWorldName[35] = 0; - save->currentMapMusic = world->trackID; - - for (int i = 0; i < 2; i++) { - save->fsTextColours[i] = world->fsTextColours[i]; - save->fsHintColours[i] = world->fsHintColours[i]; - save->hudTextColours[i] = world->hudTextColours[i]; - } + if (strncmp(save->newerWorldName, world->name, 36) == 0) { + OSReport("Already here\n"); + } else { + OSReport("Found!\n"); + strncpy(save->newerWorldName, world->name, 36); + save->newerWorldName[35] = 0; + save->currentMapMusic = world->trackID; + + for (int i = 0; i < 2; i++) { + save->fsTextColours[i] = world->fsTextColours[i]; + save->fsHintColours[i] = world->fsHintColours[i]; + save->hudTextColours[i] = world->hudTextColours[i]; + } - save->hudHintH = world->hudHintH; - save->hudHintS = world->hudHintS; - save->hudHintL = world->hudHintL; + save->hudHintH = world->hudHintH; + save->hudHintS = world->hudHintS; + save->hudHintL = world->hudHintL; - dWMHud_c::instance->hideAndShowFooter(); + dWMHud_c::instance->hideAndShowFooter(); + } } else { OSReport("Not found!\n"); } -- cgit v1.2.3 From 87cb3ef8451f6e6dc0f642d22f5335c1c4f4b064 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 06:08:02 +0200 Subject: a tiny bit of savefile RE, and default world stuff in the savefile --- fileselect.yaml | 1 + include/game.h | 25 +++++++++++++++++++++++++ src/fileselect.S | 29 +++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/fileselect.yaml b/fileselect.yaml index 90c18f9..eb8c107 100644 --- a/fileselect.yaml +++ b/fileselect.yaml @@ -147,6 +147,7 @@ hooks: - {name: DFNiceTitle, type: branch_insn, branch_type: bl, src_addr_pal: 0x8077D044, target_func: 'DFNiceTitle'} - {name: DFNiceWorldName, type: branch_insn, branch_type: bl, src_addr_pal: 0x8077DA10, target_func: 'DFNiceWorldName'} + - {name: DefaultSavefileInfo, type: branch_insn, branch_type: b, src_addr_pal: 0x800CE100, target_func: 'DefaultSavefileInfo'} # - {name: FSDebugStates, type: add_func_pointer, src_addr_pal: 0x80943E38, target_func: 'FSDebugStates'} diff --git a/include/game.h b/include/game.h index 32b3a1d..071d93e 100755 --- a/include/game.h +++ b/include/game.h @@ -153,6 +153,31 @@ bool IsWideScreen(); #define COND_SGNORMAL 0x80 #define COND_SGSECRET 0x100 + +// All of these are set by "SetWorldCompleteionBitfield" (I didn't name it) +// at 801028D0. It's called by ScStage so it doesn't depend on Nintendo maps. + +#define SAVE_BIT_EXISTS_MAYBE 1 + +// Controls whether you can QUICK SAVE or not. +// Set if 8-Castle is complete. +#define SAVE_BIT_GAME_COMPLETE 2 + +// Set when all exits are complete. +// This is defined by "ReturnWhetherConditionMaskIsValid" / "SetSomeConditionShit" +// TODO: Need to RE and fix this for Newer... +#define SAVE_BIT_ALL_EXITS 4 + +// Set when all star coins in worlds 1-8 are obtained. +// Valid levels are chosen by the condition crap as above. +#define SAVE_BIT_ALL_STAR_COINS 8 + +#define SAVE_BIT_ALL_STAR_COINS_W9 0x10 + +// Set when, well... EVERYTHING is done. +#define SAVE_BIT_EVERYTHING_TRULY_DONE 0x20 + + class SaveFirstBlock { public: char titleID[4]; // 0x00 diff --git a/src/fileselect.S b/src/fileselect.S index 16a1047..6ee1c39 100644 --- a/src/fileselect.S +++ b/src/fileselect.S @@ -247,6 +247,22 @@ FSDebugStates: addi r1, r1, 0x10 blr +.global DefaultSavefileInfo +DefaultSavefileInfo: + addi r4, r3, 0x6FC + lis r5, DefaultSavefileInfoData@h + ori r5, r5, DefaultSavefileInfoData@l + lis r6, DefaultSavefileInfoDataEnd@h + ori r6, r6, DefaultSavefileInfoDataEnd@l +DSFICopyLoop: + lwz r7, 0(r5) + stw r7, 0(r4) + addi r4, r4, 4 + addi r5, r5, 4 + cmpw r5, r6 + blt DSFICopyLoop + blr + .align 4 .data @@ -281,3 +297,16 @@ ConvertedWorldName: .short 0,0,0,0,0,0,0,0,0,0,0,0 # 12 .short 0,0,0,0,0,0,0,0,0,0,0,0 # 12 +.align 4 +DefaultSavefileInfoData: +.string "Yoshi's Island" #15 +.byte 0,0,0,0,0,0,0,0,0,0,0 # 11 +.byte 0,0,0,0,0,0,0,0,0,0 # 10 +.long 0xFFFF99FF,0x1FB423FF +.long 0x173714FF,0x3C9135FF +.long 0xFFFF99FF,0x1FB423FF +.short 0x75,0x2E,0xB +.byte 0,0 + +DefaultSavefileInfoDataEnd: +.long 0 -- cgit v1.2.3 From 261cd42b5eaad3add529a7464410fcb256fefeab Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 06:20:55 +0200 Subject: draw order fix --- src/koopatlas/hud.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index 84329bf..907f02c 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -228,6 +228,8 @@ int dWMHud_c::onCreate() { layoutLoaded = true; + layout.drawOrder = 0; + willShowHeader = false; willShowFooter = false; -- cgit v1.2.3 From cd2ceff21f680a7d33b43a6926b4e556e81d625b Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 15:35:54 +0200 Subject: fixed a possible crash bug where the HUD was accessed before it was created --- src/koopatlas/hud.cpp | 2 ++ src/koopatlas/pathmanager.cpp | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index 907f02c..892186e 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -246,6 +246,8 @@ int dWMHud_c::onCreate() { int dWMHud_c::onDelete() { + dWMHud_c::instance = 0; + if (!layoutLoaded) return true; diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 97d9265..6134dc6 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -368,7 +368,7 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) { SpammyReport("moving to path %p [%d,%d to %d,%d]\n", path, path->start->x, path->start->y, path->end->x, path->end->y); if (!path->isAvailable) { return; } - if (currentNode) + if (currentNode && dWMHud_c::instance) dWMHud_c::instance->leftNode(); calledEnteredNode = false; @@ -545,7 +545,7 @@ void dWMPathManager_c::moveThroughPath() { 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) { + if (distToEnd < 64.0f && dWMHud_c::instance) { calledEnteredNode = true; dWMHud_c::instance->enteredNode(to); } @@ -615,7 +615,8 @@ void dWMPathManager_c::moveThroughPath() { save->hudHintS = world->hudHintS; save->hudHintL = world->hudHintL; - dWMHud_c::instance->hideAndShowFooter(); + if (dWMHud_c::instance) + dWMHud_c::instance->hideAndShowFooter(); } } else { OSReport("Not found!\n"); @@ -655,7 +656,7 @@ void dWMPathManager_c::moveThroughPath() { SaveBlock *save = GetSaveFile()->GetBlock(-1); save->current_path_node = pathLayer->findNodeID(to); - if (!calledEnteredNode) + if (!calledEnteredNode && dWMHud_c::instance) dWMHud_c::instance->enteredNode(); } else { startMovementTo(to->getOppositeAvailableExitTo(currentPath)); -- cgit v1.2.3 From b216a278d3fdc1f13285e3907cd4f27de1555eeb Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 15:47:24 +0200 Subject: fuck it I can't be assed to make lives reset only when needed --- src/koopatlas/hud.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index 892186e..5293933 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -271,6 +271,7 @@ int dWMHud_c::onExecute() { playShowAnim(SHOW_FOOTER); } + setupLives(); // FUCK IT updatePressableButtonThingies(); layout.execAnimations(); -- cgit v1.2.3 From 0fc70778c02671e64b8360b7ebdbb0e8c29f0a05 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 16:58:28 +0200 Subject: star coin count, need to fix this --- src/koopatlas/hud.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index 5293933..90e769e 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -274,6 +274,10 @@ int dWMHud_c::onExecute() { setupLives(); // FUCK IT updatePressableButtonThingies(); + int scCount = getStarCoinCount(); + int scLength = 3; + WriteNumberToTextBox(&scCount, &scLength, StarCoinCounter, false); + layout.execAnimations(); layout.update(); -- cgit v1.2.3