diff options
author | Treeki <treeki@gmail.com> | 2012-09-20 15:30:05 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-09-20 15:30:05 +0200 |
commit | 05eb1400faaa957905fbbe8fa284df4ab1472a58 (patch) | |
tree | 7794b1d7af940bdf840739b4a7a96460e6933838 | |
parent | a7fc34dfdfee0c899712e0209885e40b19305d7f (diff) | |
download | kamek-05eb1400faaa957905fbbe8fa284df4ab1472a58.tar.gz kamek-05eb1400faaa957905fbbe8fa284df4ab1472a58.zip |
cleaning up in preparation for the new HUD, plus a few other changes
-rwxr-xr-x | include/game.h | 51 | ||||
-rw-r--r-- | include/newer.h | 1 | ||||
-rw-r--r-- | src/koopatlas/hud.cpp | 339 | ||||
-rw-r--r-- | src/koopatlas/hud.h | 17 | ||||
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 5 | ||||
-rw-r--r-- | src/koopatlas/shop.cpp | 22 | ||||
-rw-r--r-- | src/koopatlas/starcoin.cpp | 22 | ||||
-rw-r--r-- | 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 <game.h> -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 <newer.h> +#include <game.h> 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; +} |