diff --git a/app/main3d.cpp b/app/main3d.cpp index 94a80f1f..49ab5569 100644 --- a/app/main3d.cpp +++ b/app/main3d.cpp @@ -219,7 +219,7 @@ int main(int argc, char** argv) { currentTile = camera.GetGameTile(); logger.Debug() << "New tile: " << currentTile << "\n"; - gameRunner.mGameState.Apply([](auto& fb){ BAK::State::ClearTileRecentEncounters(fb); }); + gameRunner.mGameState.Apply(BAK::State::ClearTileRecentEncounters); } }; @@ -253,7 +253,7 @@ int main(int argc, char** argv) }}); inputHandler.Bind(GLFW_KEY_X, [&]{ if (guiManager.InMainView()) cameraPtr->RotateVerticalUp(); }); inputHandler.Bind(GLFW_KEY_Y, [&]{ if (guiManager.InMainView()) cameraPtr->RotateVerticalDown(); }); - inputHandler.Bind(GLFW_KEY_C, [&]{ if (guiManager.InMainView()) gameRunner.mGameState.Apply([](auto& fb){ BAK::State::ClearTileRecentEncounters(fb); }); }); + inputHandler.Bind(GLFW_KEY_C, [&]{ if (guiManager.InMainView()) gameRunner.mGameState.Apply(BAK::State::ClearTileRecentEncounters); }); inputHandler.Bind(GLFW_KEY_BACKSPACE, [&]{ if (root.OnKeyEvent(Gui::KeyPress{GLFW_KEY_BACKSPACE})){ ;} }); inputHandler.BindCharacter([&](char character){ if(root.OnKeyEvent(Gui::Character{character})){ ;} }); diff --git a/bak/CMakeLists.txt b/bak/CMakeLists.txt index d846d629..5acb07b0 100644 --- a/bak/CMakeLists.txt +++ b/bak/CMakeLists.txt @@ -16,6 +16,7 @@ add_library(bak dialogChoice.hpp dialogChoice.cpp dialogSources.hpp dialogTarget.hpp dialogTarget.cpp + entityType.hpp entityType.cpp fixedObject.hpp fixedObject.cpp fileBufferFactory.hpp fileBufferFactory.cpp font.hpp font.cpp diff --git a/bak/character.hpp b/bak/character.hpp index 53c67a1f..d99b89eb 100644 --- a/bak/character.hpp +++ b/bak/character.hpp @@ -259,7 +259,7 @@ class Character final : public IContainer staffCount++; } } - ASSERT(staffCount == 1); + ASSERT(staffCount <= 1); } else { @@ -274,7 +274,7 @@ class Character final : public IContainer swordCount++; } } - ASSERT(swordCount == 1); + ASSERT(swordCount <= 1); unsigned crossbowCount = 0; for (const auto& item : GetInventory().GetItems()) diff --git a/bak/encounter/encounter.hpp b/bak/encounter/encounter.hpp index 2037262c..f7ec3f22 100644 --- a/bak/encounter/encounter.hpp +++ b/bak/encounter/encounter.hpp @@ -30,9 +30,9 @@ enum class EncounterType : std::uint16_t { Background = 0, // DEF_BKGR.DAT?? teleport?? Combat = 1, // DEF_COMB.DAT - Comment = 2, // ??? + Comment = 2, // no file exists, but would be DEF_COMM.DAT Dialog = 3, // DEF_DIAL.DAT - Health = 4, // ??? + Health = 4, // no file exists, but would be DEF_COMM.DAT Sound = 5, // DEF_SOUN.DAT Town = 6, // DEF_TOWN.DAT Trap = 7, // DEF_TRAP.DAT diff --git a/bak/entityType.cpp b/bak/entityType.cpp new file mode 100644 index 00000000..63f34e55 --- /dev/null +++ b/bak/entityType.cpp @@ -0,0 +1,28 @@ +#include "bak/entityType.hpp" + +namespace BAK { + +unsigned GetContainerTypeFromEntityType(EntityType et) +{ + using enum EntityType; + switch (et) + { + case BAG: return 0; + case CHEST: return 1; + case DIRTPILE: return 2; + case TOMBSTONE: return 3; + case DEADBODY1: [[fallthrough]]; + case DEADBODY2: return 4; + case TRAP: return 5; + case BUSH1: [[fallthrough]]; + case BUSH2: [[fallthrough]]; + case BUSH3: return 6; + // 7 is shop, which is not an entity + case CRYST: return 8; + case STUMP: return 9; + case BUILDING: return 10; + default: return 0; + } +} + +} diff --git a/bak/entityType.hpp b/bak/entityType.hpp new file mode 100644 index 00000000..29841f1c --- /dev/null +++ b/bak/entityType.hpp @@ -0,0 +1,51 @@ +#pragma once + +namespace BAK { + +enum class EntityType +{ + TERRAIN = 0, + EXTERIOR = 1, + BRIDGE = 2, + INTERIOR = 3, + HILL = 4, + TREE = 5, + CHEST = 6, + DEADBODY1 = 7, + FENCE = 8, + GATE = 9, // RIFT GATE + BUILDING = 10, + TOMBSTONE = 12, + SIGN = 13, + TUNNEL1 = 14, // ALSO TUNNEL... + PIT = 15, + DEADBODY2 = 16, + DIRTPILE = 17, + CORN = 18, + FIRE = 19, + ENTRANCE = 20, + GROVE = 21, + FERN = 22, + DOOR = 23, + CRYST = 24, + ROCKPILE = 25, + BUSH1 = 26, + BUSH2 = 27, + BUSH3 = 28, + SLAB = 29, + STUMP = 30, + WELL = 31, + ENGINE = 33, + SCARECROW = 34, + TRAP = 35, + CATAPULT = 36, + COLUMN = 37, + LANDSCAPE = 38, + TUNNEL2 = 39, // with tunnel + BAG = 41, + LADDER = 42 +}; + +unsigned GetContainerTypeFromEntityType(EntityType); + +} diff --git a/bak/fmap.hpp b/bak/fmap.hpp index 81ed09b6..67f3dae9 100644 --- a/bak/fmap.hpp +++ b/bak/fmap.hpp @@ -51,6 +51,11 @@ class FMapXY return glm::vec2{0, 0}; //ASSERT(it != tiles.end()); const auto index = std::distance(tiles.begin(), it); + // There's no full map for Timirianya + if (zone.mValue == 9) + { + return glm::vec2{0, 0}; + } return mTileCoords[zone.mValue - 1][index]; } diff --git a/bak/gameData.cpp b/bak/gameData.cpp index e5f4a53e..8661ceef 100644 --- a/bak/gameData.cpp +++ b/bak/gameData.cpp @@ -175,7 +175,11 @@ Conditions GameData::LoadConditions(unsigned character) unsigned GameData::LoadChapter() { mBuffer.Seek(sChapterOffset); - return mBuffer.GetUint16LE(); + auto chapter = mBuffer.GetUint16LE(); + mBuffer.Seek(0x64); + auto chapterAgain = mBuffer.GetUint16LE(); + assert(chapter == chapterAgain); + return chapterAgain; } Royals GameData::LoadGold() @@ -204,7 +208,7 @@ Location GameData::LoadLocation() mBuffer.Seek(sLocationOffset); unsigned zone = mBuffer.GetUint8(); - ASSERT(zone < 12); + ASSERT(zone <= 12); mLogger.Info() << "LOADED: Zone:" << zone << std::endl; unsigned xtile = mBuffer.GetUint8(); @@ -212,10 +216,8 @@ Location GameData::LoadLocation() unsigned xpos = mBuffer.GetUint32LE(); unsigned ypos = mBuffer.GetUint32LE(); - //mBuffer.DumpAndSkip(5); - mBuffer.Skip(5); - std::uint16_t heading = mBuffer.GetUint8(); - mBuffer.Skip(1); + mLogger.Info() << "Unknown: " << mBuffer.GetArray<5>() << "\n"; + std::uint16_t heading = mBuffer.GetUint16LE() >> 8; mLogger.Info() << "Tile: " << xtile << "," << ytile << std::endl; mLogger.Info() << "Pos: " << xpos << "," << ypos << std::endl; diff --git a/bak/gameState.hpp b/bak/gameState.hpp index ac509f0b..66a02adb 100644 --- a/bak/gameState.hpp +++ b/bak/gameState.hpp @@ -132,18 +132,18 @@ class GameState const TextVariableStore& GetTextVariableStore() const { return mTextVariableStore; } TextVariableStore& GetTextVariableStore() { return mTextVariableStore; } - template - bool Apply(F&& func) + template + bool Apply(F&& func, Args&&... args) { if (mGameData) { - if constexpr (std::is_same_vGetFileBuffer())), bool>) + if constexpr (std::is_same_vGetFileBuffer(), args...)), bool>) { - return std::invoke(func, mGameData->GetFileBuffer()); + return std::invoke(func, mGameData->GetFileBuffer(), args...); } else { - std::invoke(func, mGameData->GetFileBuffer()); + std::invoke(func, mGameData->GetFileBuffer(), args...); } } diff --git a/bak/state/encounter.cpp b/bak/state/encounter.cpp index 64dd731d..8a8f8cce 100644 --- a/bak/state/encounter.cpp +++ b/bak/state/encounter.cpp @@ -20,9 +20,7 @@ bool CheckActive( zone, encounter.GetTileIndex(), encounterIndex); - const bool encounterFlag1450 = ReadEventBool( - fb, - CalculateRecentEncounterStateFlag(encounterIndex)); + const bool recentlyEncountered = CheckRecentlyEncountered(fb, encounterIndex); // event flag 1 - this flag must be set to encounter the event const bool eventFlag1 = encounter.mSaveAddress != 0 ? (ReadEventBool(fb, encounter.mSaveAddress) == 1) @@ -32,7 +30,7 @@ bool CheckActive( ? ReadEventBool(fb, encounter.mSaveAddress2) : false; return !(alreadyEncountered - || encounterFlag1450 + || recentlyEncountered || eventFlag1 || eventFlag2); } @@ -51,8 +49,9 @@ bool CheckCombatActive( assert(std::holds_alternative(encounter.GetEncounter())); const auto combatIndex = std::get(encounter.GetEncounter()).mCombatIndex; - // If this flag is not set then this combat hasn't been seen - const bool encounterFlag1464 = !CheckCombatEncounterStateFlag(fb, combatIndex); + + // If this flag is set then this combat hasn't been seen + const bool encounterFlag1464 = CheckCombatEncounterStateFlag(fb, combatIndex); // event flag 1 - this flag must be set to encounter the event const bool eventFlag1 = encounter.mSaveAddress != 0 @@ -63,6 +62,11 @@ bool CheckCombatActive( ? ReadEventBool(fb, encounter.mSaveAddress2) : false; + Logging::LogInfo(__FUNCTION__) << " alreadyEncountered: " << alreadyEncountered + << " combatEncounterStateFlag: " << encounterFlag1464 + << " eventFlag1: " << eventFlag1 + << " eventFlag2: " << eventFlag2 << "\n"; + return !(alreadyEncountered || encounterFlag1464 || eventFlag1 @@ -98,10 +102,7 @@ void SetPostDialogEventFlags( } // Inhibit for this tile - SetEventFlagTrue( - fb, - CalculateRecentEncounterStateFlag( - encounterIndex)); + SetRecentlyEncountered(fb, encounterIndex); } } @@ -214,12 +215,26 @@ unsigned CalculateRecentEncounterStateFlag( return offset + encounterIndex; } +bool CheckRecentlyEncountered(FileBuffer& fb, std::uint8_t encounterIndex) +{ + return ReadEventBool(fb, CalculateRecentEncounterStateFlag(encounterIndex)); +} + +void SetRecentlyEncountered(FileBuffer& fb, std::uint8_t encounterIndex) +{ + SetEventFlagTrue( + fb, + CalculateRecentEncounterStateFlag( + encounterIndex)); +} + void ClearTileRecentEncounters( FileBuffer& fb) { for (unsigned i = 0; i < 10; i++) { SetEventFlagFalse(fb, CalculateRecentEncounterStateFlag(i)); + SetEventFlagFalse(fb, CalculateCombatEncounterScoutedStateFlag(i)); } } } diff --git a/bak/state/encounter.hpp b/bak/state/encounter.hpp index 01613b64..333b4bc8 100644 --- a/bak/state/encounter.hpp +++ b/bak/state/encounter.hpp @@ -85,6 +85,8 @@ void SetCombatEncounterScoutedState( FileBuffer&, std::uint8_t encounterIndex, bool state); -void ClearTileRecentEncounters(FileBuffer& fb); +void SetRecentlyEncountered(FileBuffer&, std::uint8_t encounterIndex); +bool CheckRecentlyEncountered(FileBuffer&, std::uint8_t encounterIndex); +void ClearTileRecentEncounters(FileBuffer&); } diff --git a/bak/worldFactory.hpp b/bak/worldFactory.hpp index bb92cef9..7265b1b5 100644 --- a/bak/worldFactory.hpp +++ b/bak/worldFactory.hpp @@ -16,56 +16,13 @@ #include "graphics/meshObject.hpp" #include "bak/fileBufferFactory.hpp" +#include "bak/entityType.hpp" #include #include namespace BAK { -enum class EntityType -{ - TERRAIN = 0, - EXTERIOR = 1, - BRIDGE = 2, - INTERIOR = 3, - HILL = 4, - TREE = 5, - CHEST = 6, - DEADBODY1 = 7, - FENCE = 8, - GATE = 9, // RIFT GATE - BUILDING = 10, - TOMBSTONE = 12, - SIGN = 13, - TUNNEL1 = 14, // ALSO TUNNEL... - PIT = 15, - DEADBODY2 = 16, - DIRTPILE = 17, - CORN = 18, - FIRE = 19, - ENTRANCE = 20, - GROVE = 21, - FERN = 22, - DOOR = 23, - CRYST = 24, - ROCKPILE = 25, - BUSH1 = 26, - BUSH2 = 27, - BUSH3 = 28, - SLAB = 29, - STUMP = 30, - WELL = 31, - ENGINE = 33, - SCARECROW = 34, - TRAP = 35, - CATAPULT = 36, - COLUMN = 37, - LANDSCAPE = 38, - TUNNEL2 = 39, // with tunnel - BAG = 41, - LADDER = 42 -}; - class ZoneTextureStore { public: diff --git a/game/gameRunner.hpp b/game/gameRunner.hpp index 2b8b57d0..a0da9573 100644 --- a/game/gameRunner.hpp +++ b/game/gameRunner.hpp @@ -9,6 +9,7 @@ #include "bak/dialog.hpp" #include "bak/encounter/encounter.hpp" #include "bak/encounter/teleport.hpp" +#include "bak/state/encounter.hpp" #include "bak/monster.hpp" #include "bak/types.hpp" #include "bak/zone.hpp" @@ -211,7 +212,7 @@ class GameRunner : public BAK::IZoneLoader mCurrentInteractable = mInteractableFactory.MakeInteractable(et); ASSERT(mCurrentInteractable); - mCurrentInteractable->BeginInteraction(container); + mCurrentInteractable->BeginInteraction(container, et); /* if (container.HasEncounter() && container.GetEncounter().mEncounterPos) @@ -227,48 +228,69 @@ class GameRunner : public BAK::IZoneLoader const BAK::Encounter::Encounter& encounter, const BAK::Encounter::Combat& combat) { - if (!mGameState.Apply([&](auto& fb){ return BAK::State::CheckCombatActive(fb, encounter, mGameState.GetZone()); })) + mLogger.Info() << __FUNCTION__ << " Checking combat active\n"; + if (!mGameState.Apply(BAK::State::CheckCombatActive, encounter, mGameState.GetZone())) { + mLogger.Info() << __FUNCTION__ << " Combat inactive\n"; return; } - //if (!combat.mIsAmbush) - //{ - // //return {combatActive, combatNotScouted} - //} - //else - //{ - // //if (arg_dontDoCombatIfIsAmbush) - // //{ - // // return {combatInActive, combatNotScouted} - // //} - // if (false) - // { - // ; - // } - // else - // { - // if (!mGameState.mGameData->CheckRecentlyEncountered(encounter.GetIndex().mValue)) - // { - // mGameState.mGameData->SetRecentlyEncountered(encounter.GetIndex().mValue, true); - // auto chance = GetRandomNumber(0, 0xfff) / 100; - // auto bestScoutSkill = mGameState.GetParty().GetSkill(BAK::SkillType::Scout, true); - // if (bestScoutSkill > chance) - // { - // mGameState.GetParty().ImproveSkillForAll( - // BAK::SkillType::Scout, SkillChange::ExercisedSkill, 1); - // // RunDialog combat.mScoutDialog - // mGameState.mGameData.SetCombatEncounterScoutedState( - // encounter.GetIndex().mValue, true); - // // return {combatNotActive, combatScouted} - // } - // else - // { - // // return {combatActive, combatNotScouted} - // } - // } - // } - //} + bool combatActive = false; + bool combatScouted = false; + if (!combat.mIsAmbush) + { + mLogger.Info() << __FUNCTION__ << " Combat is not ambush\n"; + combatActive = true; + combatScouted = true; + } + else + { + // This seems to be a variable used to prevent the scouting of multiple combats + // at once... + const auto arg_dontDoCombatIfIsAmbush = false; + if (arg_dontDoCombatIfIsAmbush) + { + combatActive = false; + combatScouted = false; + } + else + { + if (!mGameState.Apply(BAK::State::CheckRecentlyEncountered, encounter.GetIndex().mValue)) + { + mGameState.Apply(BAK::State::SetRecentlyEncountered, encounter.GetIndex().mValue); + auto chance = GetRandomNumber(0, 0xfff) % 100; + const auto [character, scoutSkill] = mGameState.GetParty().GetSkill(BAK::SkillType::Scouting, true); + mLogger.Info() << __FUNCTION__ << " Trying to scout combat: " + << scoutSkill << " chance: " << chance << "\n"; + if (scoutSkill > chance) + { + mGameState.GetParty().ImproveSkillForAll( + BAK::SkillType::Scouting, BAK::SkillChange::ExercisedSkill, 1); + // RunDialog combat.mScoutDialog + mGuiManager.StartDialog( + combat.mScoutDialog, + false, + false, + &mDynamicDialogScene); + + mGameState.Apply(BAK::State::SetCombatEncounterScoutedState, + encounter.GetIndex().mValue, true); + + combatActive = false; + combatScouted = true; + } + else + { + combatActive = true; + combatScouted = false; + } + } + else + { + mLogger.Info() << __FUNCTION__ << " Combat was scouted already\n"; + } + } + } //mGuiManager.StartDialog( // block.mDialog, @@ -280,6 +302,88 @@ class GameRunner : public BAK::IZoneLoader //mGameState.SetPostEnableOrDisableEventFlags(encounter); } + //void CheckCombatStealhAvoided() + //{ + // auto lowestStealth = ... + // if (lowestStealh < 0x5a) // 90 + // { + // lowestStealth *= 0x1e; // 30 + // lowestStealth += (lowestStealth / 100); + // } + // if (lowestStealth > 0x5a) lowestStealth = 0x5a; + + // if (combatIsAmbush) + // { + // if (isSpellActive(Spell_0)) // dragon's breath + // { + // lowestStealth = lowestStealth + ((100 - lowestStealth) >> 1) + // } + // } + + // auto chance = GetRandomNumber(0, 0xfff) % 100; + // if (lowestStealth > chance) + // { + // mGameState.GetParty().ImproveSkillForAll( + // BAK::SkillType::Stealth , BAK::SkillChange::ExercisedSkill, 1); + + // return; // avoided combat due to stealth! + // } + + // // Check whether players are in valid combatable position??? + // auto timeOfScouting = LoadTimeOfScouting(ThisCombat); + // auto timeDiff = mGameState.CurrentTime() - timeOfScouting; + // if ((timeDiff / 0x1e) > 0x1e) // within scouting valid time + // { + // auto chance = GetRandomNumber(0, 0xfff) % 100; + // if (chance > lowestStealth) + // { + // DialogContext_7530 = 1; + // // Failed to scout + // } + // else + // { + // mGameState.GetParty().ImproveSkillForAll( + // BAK::SkillType::Stealth , BAK::SkillChange::ExercisedSkill, 1); + // DialogContext_7530 = 0; + // } + // } + // else + // { + // DialogContext_7530 = 2; + // } + + // SetDialogTextVariable(monster, combat.firstMonster.index); + // if (combat.mEntryDialog != 0) + // { + // RunDialog(combat.mEntryDialog()); + // } + + // bool combatRetreated; + // auto combatResult = EnterCombatScreen(surprisedEnemy, &combatRetreated); + // //recordTimeOfCombat at (combatIndex << 2) + 0x3967 + // if (combatResult == 2) + // { + // // retreat to a combat retreat location based on player entry + // } + // else if (combatResult == 1) + // { + // // Victory? + // if (encounter.haveSaveAddr3) + // { + // setSaveAddr3 to 1 + // } + // } + + // setEncounterState190 to 1 + // setEncounterState1464 to 1 + // setFlagsPostCombat + + // if (combatResult == 3) + // { + // } + // + //} + void DoBlockEncounter( const BAK::Encounter::Encounter& encounter, const BAK::Encounter::Block& block) diff --git a/game/interactable/IInteractable.hpp b/game/interactable/IInteractable.hpp index 05017fbb..ff92fe51 100644 --- a/game/interactable/IInteractable.hpp +++ b/game/interactable/IInteractable.hpp @@ -1,6 +1,7 @@ #pragma once #include "bak/container.hpp" +#include "bak/entityType.hpp" namespace Game { @@ -9,7 +10,7 @@ using EncounterCallback = std::function; class IInteractable { public: - virtual void BeginInteraction(BAK::GenericContainer&) = 0; + virtual void BeginInteraction(BAK::GenericContainer&, BAK::EntityType) = 0; virtual void EncounterFinished() = 0; virtual ~IInteractable() {}; diff --git a/game/interactable/building.hpp b/game/interactable/building.hpp index 44f47ed5..6b19236f 100644 --- a/game/interactable/building.hpp +++ b/game/interactable/building.hpp @@ -49,7 +49,7 @@ class Building : public IInteractable mEncounterCallback{encounterCallback} {} - void BeginInteraction(BAK::GenericContainer& building) override + void BeginInteraction(BAK::GenericContainer& building, BAK::EntityType) override { ASSERT(mState == State::Idle); mCurrentBuilding = &building; @@ -205,7 +205,7 @@ class Building : public IInteractable ASSERT(mState == State::ShowInventory); if (mCurrentBuilding->HasInventory()) { - mGuiManager.ShowContainer(mCurrentBuilding); + mGuiManager.ShowContainer(mCurrentBuilding, BAK::EntityType::BUILDING); } mState = State::Idle; } diff --git a/game/interactable/chest.hpp b/game/interactable/chest.hpp index b365fc89..3818272d 100644 --- a/game/interactable/chest.hpp +++ b/game/interactable/chest.hpp @@ -44,7 +44,7 @@ class Chest : public IInteractable mState{State::Idle} {} - void BeginInteraction(BAK::GenericContainer& chest) override + void BeginInteraction(BAK::GenericContainer& chest, BAK::EntityType) override { ASSERT(mState == State::Idle); @@ -214,7 +214,7 @@ class Chest : public IInteractable 1); } - mGuiManager.ShowContainer(mCurrentChest); + mGuiManager.ShowContainer(mCurrentChest, BAK::EntityType::CHEST); } void TryUnlockChest() diff --git a/game/interactable/door.hpp b/game/interactable/door.hpp index a30f7846..f446e890 100644 --- a/game/interactable/door.hpp +++ b/game/interactable/door.hpp @@ -37,7 +37,7 @@ class Door : public IInteractable mEncounterCallback{encounterCallback} {} - void BeginInteraction(BAK::GenericContainer& container) override + void BeginInteraction(BAK::GenericContainer& container, BAK::EntityType) override { mContainer = &container; diff --git a/game/interactable/generic.hpp b/game/interactable/generic.hpp index f93307b0..92ba1aba 100644 --- a/game/interactable/generic.hpp +++ b/game/interactable/generic.hpp @@ -8,6 +8,7 @@ #include "bak/dialogSources.hpp" #include "bak/gameState.hpp" #include "bak/itemNumbers.hpp" +#include "bak/types.hpp" #include "gui/IDialogScene.hpp" #include "gui/IGuiManager.hpp" @@ -37,9 +38,10 @@ class Generic : public IInteractable mEncounterCallback{encounterCallback} {} - void BeginInteraction(BAK::GenericContainer& container) override + void BeginInteraction(BAK::GenericContainer& container, BAK::EntityType entityType) override { mContainer = &container; + mEntityType = entityType; if (container.HasDialog()) StartDialog(container.GetDialog().mDialog); @@ -61,7 +63,7 @@ class Generic : public IInteractable ASSERT(mContainer); if (mContainer->HasInventory()) { - mGuiManager.ShowContainer(mContainer); + mGuiManager.ShowContainer(mContainer, mEntityType); } } @@ -83,6 +85,7 @@ class Generic : public IInteractable Gui::DynamicDialogScene mDialogScene; BAK::Target mDefaultDialog; BAK::GenericContainer* mContainer; + BAK::EntityType mEntityType; const EncounterCallback& mEncounterCallback; }; diff --git a/game/interactable/ladder.hpp b/game/interactable/ladder.hpp index 2b7e357b..114471a8 100644 --- a/game/interactable/ladder.hpp +++ b/game/interactable/ladder.hpp @@ -39,7 +39,7 @@ class Ladder : public IInteractable mState{State::Idle} {} - void BeginInteraction(BAK::GenericContainer& ladder) override + void BeginInteraction(BAK::GenericContainer& ladder, BAK::EntityType) override { ASSERT(mState == State::Idle); diff --git a/game/interactable/tomb.hpp b/game/interactable/tomb.hpp index 88f3bdf6..90f32675 100644 --- a/game/interactable/tomb.hpp +++ b/game/interactable/tomb.hpp @@ -6,6 +6,8 @@ #include "bak/container.hpp" #include "bak/dialog.hpp" #include "bak/dialogSources.hpp" +#include "bak/entityType.hpp" +#include "bak/dialog.hpp" #include "bak/gameState.hpp" #include "bak/itemNumbers.hpp" @@ -41,7 +43,7 @@ class Tomb : public IInteractable mEncounterCallback{encounterCallback} {} - void BeginInteraction(BAK::GenericContainer& tomb) override + void BeginInteraction(BAK::GenericContainer& tomb, BAK::EntityType) override { mCurrentTomb = &tomb; mGameState.SetDialogContext(0); @@ -149,7 +151,7 @@ class Tomb : public IInteractable 1); } - mGuiManager.ShowContainer(mCurrentTomb); + mGuiManager.ShowContainer(mCurrentTomb, BAK::EntityType::TOMBSTONE); } private: diff --git a/gui/IGuiManager.hpp b/gui/IGuiManager.hpp index aa231998..4240e0d2 100644 --- a/gui/IGuiManager.hpp +++ b/gui/IGuiManager.hpp @@ -6,6 +6,7 @@ #include "gui/IAnimator.hpp" #include "bak/dialog.hpp" +#include "bak/entityType.hpp" #include "bak/hotspot.hpp" #include "bak/saveManager.hpp" #include "bak/types.hpp" @@ -31,7 +32,7 @@ class IGuiManager virtual void ExitSimpleScreen() = 0; virtual void ShowInventory(BAK::ActiveCharIndex) = 0; - virtual void ShowContainer(BAK::IContainer*) = 0; + virtual void ShowContainer(BAK::IContainer*, BAK::EntityType containerType) = 0; virtual void SelectItem(std::function>)>&&) = 0; virtual void ExitInventory() = 0; diff --git a/gui/gdsScene.cpp b/gui/gdsScene.cpp index e969ce7a..0f6f0691 100644 --- a/gui/gdsScene.cpp +++ b/gui/gdsScene.cpp @@ -403,7 +403,7 @@ void GDSScene::EnterContainer() { auto* container = mGameState.GetContainerForGDSScene(mReference); if (container != nullptr) - mGuiManager.ShowContainer(container); + mGuiManager.ShowContainer(container, BAK::EntityType::BAG); } void GDSScene::DoBard() diff --git a/gui/guiManager.hpp b/gui/guiManager.hpp index 7807e02e..f11ce8b6 100644 --- a/gui/guiManager.hpp +++ b/gui/guiManager.hpp @@ -398,7 +398,7 @@ class GuiManager final : public Widget, public IGuiManager }); } - void ShowContainer(BAK::IContainer* container) override + void ShowContainer(BAK::IContainer* container, BAK::EntityType containerType) override { mCursor.PushCursor(0); ASSERT(container); @@ -409,7 +409,7 @@ class GuiManager final : public Widget, public IGuiManager }}); mInventoryScreen.SetSelectionMode(false, nullptr); - mInventoryScreen.SetContainer(container); + mInventoryScreen.SetContainer(container, containerType); mLogger.Debug() << __FUNCTION__ << " Pushing inv\n"; mScreenStack.PushScreen(&mInventoryScreen); } diff --git a/gui/inventory/inventoryScreen.cpp b/gui/inventory/inventoryScreen.cpp index 411f07c1..4e8cc99c 100644 --- a/gui/inventory/inventoryScreen.cpp +++ b/gui/inventory/inventoryScreen.cpp @@ -164,7 +164,7 @@ void InventoryScreen::ClearContainer() mDisplayContainer = false; } -void InventoryScreen::SetContainer(BAK::IContainer* container) +void InventoryScreen::SetContainer(BAK::IContainer* container, BAK::EntityType entityType) { ASSERT(container != nullptr); @@ -177,7 +177,7 @@ void InventoryScreen::SetContainer(BAK::IContainer* container) } else { - SetContainerTypeImage(0); + SetContainerTypeImage(BAK::GetContainerTypeFromEntityType(entityType)); mContainerScreen.SetContainer(container); } diff --git a/gui/inventory/inventoryScreen.hpp b/gui/inventory/inventoryScreen.hpp index f0257e72..8f6a3a97 100644 --- a/gui/inventory/inventoryScreen.hpp +++ b/gui/inventory/inventoryScreen.hpp @@ -72,7 +72,8 @@ class InventoryScreen : public Widget void SetSelectionMode(bool, std::function>)>&&); void ClearContainer(); - void SetContainer(BAK::IContainer* container); + // containerType determines the image used from INVMISC.BMX + void SetContainer(BAK::IContainer* container, BAK::EntityType entityType); /* Widget */ bool OnMouseEvent(const MouseEvent& event) override;