From 9ae897e419916b5cb8ec8977ae37196297f1adef Mon Sep 17 00:00:00 2001 From: Treeki Date: Sun, 7 Oct 2012 18:35:10 +0200 Subject: added Save window on map --- kamek_pal.x | 1 + src/koopatlas/core.cpp | 7 +++++++ src/koopatlas/core.h | 2 ++ src/koopatlas/pathmanager.cpp | 27 +++++++++++++++++++++++++++ src/koopatlas/pathmanager.h | 1 + 5 files changed, 38 insertions(+) diff --git a/kamek_pal.x b/kamek_pal.x index 4a97bc6..bf9fd85 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -1073,6 +1073,7 @@ SECTIONS { _ZN9SaveBlock17GetLevelConditionEii = 0x800CE490; GetLevelCondition__9SaveBlockFii = 0x800CE490; + CheckLevelCondition__9SaveBlockFiii = 0x800CE4B0; _Z20CheckIfWeCantDoStuffv = 0x8076DB90; _Z15QueryGlobal5758j = 0x800B3B50; diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp index b43b62a..8584ee9 100644 --- a/src/koopatlas/core.cpp +++ b/src/koopatlas/core.cpp @@ -1057,6 +1057,13 @@ int dScKoopatlas_c::getIndexForMapName(const char *name) { } +void dScKoopatlas_c::showSaveWindow() { + state.setState(&StateID_SaveOpen); + YESNO_TYPE(yesNoWindow) = 1; + YESNO_VISIBLE(yesNoWindow) = 1; +} + + void NewerMapDrawFunc() { Reset3DState(); SetCurrentCameraID(0); diff --git a/src/koopatlas/core.h b/src/koopatlas/core.h index cfac014..7e86d72 100644 --- a/src/koopatlas/core.h +++ b/src/koopatlas/core.h @@ -124,6 +124,8 @@ class dScKoopatlas_c : public dScene_c { bool canDoStuff(); bool mapIsRunning(); + + void showSaveWindow(); }; #endif diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 64e001a..49ba3cd 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -4,6 +4,8 @@ #include "koopatlas/player.h" #include +static u8 MaybeFinishingLevel[2] = {0xFF,0xFF}; + void dWMPathManager_c::setup() { isMoving = false; isJumping = false; @@ -107,6 +109,16 @@ void dWMPathManager_c::setup() { for (int i = 0; i < pathLayer->nodeCount; i++) if (pathLayer->nodes[i]->type == dKPNode_s::LEVEL) pathLayer->nodes[i]->setupNodeExtra(); + + // did we just beat a level? + if (MaybeFinishingLevel[0] != 0xFF) { + SaveBlock *save = GetSaveFile()->GetBlock(-1); + if (save->CheckLevelCondition(MaybeFinishingLevel[0], MaybeFinishingLevel[1], COND_NORMAL)) { + shouldRequestSave = true; + } + + MaybeFinishingLevel[0] = 0xFF; + } } static u8 *PathAvailabilityData = 0; @@ -120,6 +132,16 @@ dWMPathManager_c::~dWMPathManager_c() { delete[] NodeAvailabilityData; NodeAvailabilityData = 0; } + + if (isEnteringLevel) { + SaveBlock *save = GetSaveFile()->GetBlock(-1); + if (enteredLevel->displayLevel >= 21 && enteredLevel->displayLevel <= 28 && enteredLevel->displayLevel != 26) { + if (!save->CheckLevelCondition(enteredLevel->worldSlot, enteredLevel->levelSlot, COND_NORMAL)) { + MaybeFinishingLevel[0] = enteredLevel->worldSlot; + MaybeFinishingLevel[1] = enteredLevel->levelSlot; + } + } + } } void dWMPathManager_c::unlockPaths() { @@ -348,6 +370,11 @@ void dWMPathManager_c::execute() { return; } + if (shouldRequestSave) { + dScKoopatlas_c::instance->showSaveWindow(); + shouldRequestSave = false; + } + int nowPressed = Remocon_GetPressed(GetActiveRemocon()); if (isMoving) { diff --git a/src/koopatlas/pathmanager.h b/src/koopatlas/pathmanager.h index d0e1de0..98a68d6 100644 --- a/src/koopatlas/pathmanager.h +++ b/src/koopatlas/pathmanager.h @@ -63,6 +63,7 @@ class dWMPathManager_c { bool evaluateUnlockCondition(u8 *&in, SaveBlock *save, int stack); public: + bool shouldRequestSave; bool isEnteringLevel; bool calledEnteredNode; -- cgit v1.2.3