diff options
author | Treeki <treeki@gmail.com> | 2012-09-27 00:51:43 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-09-27 00:51:43 +0200 |
commit | 014f3668eb47b1576bdc182b1db00417f9938cf1 (patch) | |
tree | cf7ade143858d17eb9d7c8114a67b82d60523a59 /src/koopatlas | |
parent | 46b65dfd76411bec6f8356c581f337f8a1944013 (diff) | |
download | kamek-014f3668eb47b1576bdc182b1db00417f9938cf1.tar.gz kamek-014f3668eb47b1576bdc182b1db00417f9938cf1.zip |
added untested support for world change nodes
Diffstat (limited to 'src/koopatlas')
-rw-r--r-- | src/koopatlas/hud.cpp | 50 | ||||
-rw-r--r-- | src/koopatlas/hud.h | 9 | ||||
-rw-r--r-- | src/koopatlas/mapdata.cpp | 16 | ||||
-rw-r--r-- | src/koopatlas/mapdata.h | 17 | ||||
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 32 |
5 files changed, 111 insertions, 13 deletions
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 |