diff --git a/Adventures in Lestoria/ArtificerWindow.cpp b/Adventures in Lestoria/ArtificerWindow.cpp index 49d4b256..eb5bbfb7 100644 --- a/Adventures in Lestoria/ArtificerWindow.cpp +++ b/Adventures in Lestoria/ArtificerWindow.cpp @@ -48,13 +48,13 @@ INCLUDE_game void Menu::InitializeArtificerWindow(){ Menu*artificerWindow=CreateMenu(ARTIFICER,CENTERED,vi2d{144,144}); - - artificerWindow->ADD("Refine Button",MenuComponent)(geom2d::rect{{0.f,4.f},{144.f,24.f}},"Refine",[](MenuFuncData data){ - Menu::OpenMenu(MenuType::ARTIFICER_REFINE); + + artificerWindow->ADD("Disassemble Button",MenuComponent)(geom2d::rect{{0.f,4.f},{144.f,24.f}},"Disassemble",[](MenuFuncData data){ + Menu::OpenMenu(MenuType::ARTIFICER_DISASSEMBLE); return true; },vf2d{2.f,2.f},ButtonAttr::FIT_TO_LABEL)END; - artificerWindow->ADD("Disassemble Button",MenuComponent)(geom2d::rect{{0.f,32.f},{144.f,24.f}},"Disassemble",[](MenuFuncData data){ - Menu::OpenMenu(MenuType::ARTIFICER_DISASSEMBLE); + artificerWindow->ADD("Refine Button",MenuComponent)(geom2d::rect{{0.f,32.f},{144.f,24.f}},"Refine",[](MenuFuncData data){ + Menu::OpenMenu(MenuType::ARTIFICER_REFINE); return true; },vf2d{2.f,2.f},ButtonAttr::FIT_TO_LABEL)END; artificerWindow->ADD("Enchant Button",MenuComponent)(geom2d::rect{{0.f,60.f},{144.f,24.f}},"Enchant",[](MenuFuncData data){ diff --git a/Adventures in Lestoria/ConnectionPoint.cpp b/Adventures in Lestoria/ConnectionPoint.cpp index e389152e..32489a2e 100644 --- a/Adventures in Lestoria/ConnectionPoint.cpp +++ b/Adventures in Lestoria/ConnectionPoint.cpp @@ -55,6 +55,6 @@ void ConnectionPoint::ResetVisitedFlag(){ visited=false; } -const bool ConnectionPoint::Visited()const{ +[[nodiscard]]const bool ConnectionPoint::Visited()const{ return visited; } \ No newline at end of file diff --git a/Adventures in Lestoria/NPC.cpp b/Adventures in Lestoria/NPC.cpp index 53b06421..b94f047b 100644 --- a/Adventures in Lestoria/NPC.cpp +++ b/Adventures in Lestoria/NPC.cpp @@ -91,6 +91,12 @@ void Monster::STRATEGY::NPC(Monster&m,float fElapsedTime,std::string strategy){ VisualNovel::LoadDialog("ARTIFICER_INTRO",[](){Menu::OpenMenu(MenuType::ARTIFICER);}); }else{ Menu::OpenMenu(MenuType::ARTIFICER); + + bool locked=!Unlock::IsUnlocked("NPCs.Artificer.Enchant Crafting Unlock Condition"_S); + std::string enchantButtonLabel="Enchant"; + if(locked)enchantButtonLabel="???"; + Component(ARTIFICER,"Enchant Button")->SetGrayedOut(locked); + Component(ARTIFICER,"Enchant Button")->SetLabel(enchantButtonLabel); } } } diff --git a/Adventures in Lestoria/SaveFile.cpp b/Adventures in Lestoria/SaveFile.cpp index e5f61f48..e5e7428b 100644 --- a/Adventures in Lestoria/SaveFile.cpp +++ b/Adventures in Lestoria/SaveFile.cpp @@ -126,9 +126,16 @@ const void SaveFile::SaveGame(){ if(unlockName=="WORLD_MAP")continue; //This is a special exception, because the world map is not an actual stage. saveFile["Unlocks"][unlockName].SetString("True"); - auto opt_cp=State_OverworldMap::ConnectionPointFromString(unlockName); - if(!opt_cp.has_value())continue; //Harmless, we probably just deleted the map. - if(opt_cp.value()->Visited()){ + auto cps=State_OverworldMap::ConnectionPointsFromString(unlockName); + if(cps.empty())continue; //Harmless, we probably just deleted the map. + bool visited{false}; + for(const ConnectionPoint&cp:cps){ + if(cp.Visited()){ + visited=true; + break; + } + } + if(visited){ saveFile["Unlocks"][unlockName].SetString("True",1U); }else{ saveFile["Unlocks"][unlockName].SetString("False",1U); @@ -412,9 +419,8 @@ void SaveFile::LoadFile(){ for(const auto&[key,data]:loadFile["Unlocks"].GetOrderedKeys()){ Unlock::UnlockArea(key); if(data.GetValueCount()>1&&data.GetBool(1U)){ - auto opt_cp=State_OverworldMap::ConnectionPointFromString(key); - if(!opt_cp)continue; //Harmless, it just means the connection point used to exist and doesn't anymore. - else opt_cp.value()->SetVisited(); + auto cps=State_OverworldMap::ConnectionPointsFromString(key); + for(ConnectionPoint&cp:cps)cp.SetVisited(); } } } diff --git a/Adventures in Lestoria/State_OverworldMap.cpp b/Adventures in Lestoria/State_OverworldMap.cpp index 38484953..e7cd0a26 100644 --- a/Adventures in Lestoria/State_OverworldMap.cpp +++ b/Adventures in Lestoria/State_OverworldMap.cpp @@ -253,7 +253,8 @@ ConnectionPoint&State_OverworldMap::GetCurrentConnectionPoint(){ void State_OverworldMap::StartLevel(){ game->UpdateDiscordStatus(State_OverworldMap::GetCurrentConnectionPoint().name,game->GetPlayer()->GetClassName()); SaveFile::SaveGame(); - State_OverworldMap::GetCurrentConnectionPoint().SetVisited(); + auto connectionPoints{State_OverworldMap::ConnectionPointsFromString(State_OverworldMap::GetCurrentConnectionPoint().map)}; + for(ConnectionPoint&cp:connectionPoints)cp.SetVisited(); if(State_OverworldMap::GetCurrentConnectionPoint().type.starts_with("STORY")){ VisualNovel::LoadVisualNovel(State_OverworldMap::GetCurrentConnectionPoint().map); }else @@ -277,10 +278,16 @@ void State_OverworldMap::UpdateCurrentConnectionPoint(const ConnectionPoint&conn } } -std::optionalState_OverworldMap::ConnectionPointFromString(std::string_view mapName){ - auto foundItem=std::find_if(connections.begin(),connections.end(),[&](ConnectionPoint&cp){return cp.map==mapName;}); - if(foundItem!=connections.end())return &*foundItem; - return {}; +std::vector>State_OverworldMap::ConnectionPointsFromString(std::string_view mapName){ + std::vector>matchedConnections; + std::copy_if(connections.begin(),connections.end(),std::back_inserter(matchedConnections),[&mapName](const ConnectionPoint&cp){return cp.map==mapName;}); + return matchedConnections; +} + +void State_OverworldMap::ResetConnectionPointsWithMapName(std::string_view mapName){ + auto matchedConnectionPoints{State_OverworldMap::ConnectionPointsFromString(mapName)}; + if(matchedConnectionPoints.size()==0)ERR(std::format("WARNING! Could not find any connection points with name {} for resetting! THIS SHOULD NOT BE HAPPENING!",mapName)); + for(ConnectionPoint&cp:matchedConnectionPoints)cp.ResetVisitedFlag(); } void State_OverworldMap::ResetConnectionPoints(){ diff --git a/Adventures in Lestoria/State_OverworldMap.h b/Adventures in Lestoria/State_OverworldMap.h index 39974313..34dbc6ef 100644 --- a/Adventures in Lestoria/State_OverworldMap.h +++ b/Adventures in Lestoria/State_OverworldMap.h @@ -56,7 +56,8 @@ public: static bool HasStageMarker(std::string connectionName); static void SetStageMarker(std::string connectionName); static ConnectionPoint&ConnectionPointFromIndex(int ind); - static std::optionalConnectionPointFromString(std::string_view mapName); + static std::vector>ConnectionPointsFromString(std::string_view mapName); + static void ResetConnectionPointsWithMapName(std::string_view mapName); static void ResetConnectionPoints(); virtual void OnStateChange(GameState*prevState)override final; virtual void OnUserUpdate(AiL*game)override final; diff --git a/Adventures in Lestoria/Unlock.cpp b/Adventures in Lestoria/Unlock.cpp index cd5a550e..d32023c7 100644 --- a/Adventures in Lestoria/Unlock.cpp +++ b/Adventures in Lestoria/Unlock.cpp @@ -57,7 +57,14 @@ void Unlock::Initialize(){ void Unlock::UnlockArea(std::string mapName){ if(mapName=="NPCs.Sherman.Potion Crafting Unlock Condition"_S&& //When we beat the bonus chapter 1 fight, before sherman's potion crafting is unlocked, if the current map we just unlocked for is the bonus boss stage we will notify the Hub connection point and reset it so the player has a notification to go there again. - !Unlock::IsUnlocked("NPCs.Sherman.Potion Crafting Unlock Condition"_S))State_OverworldMap::ConnectionPointFromString("HUB").value()->ResetVisitedFlag(); + !Unlock::IsUnlocked("NPCs.Sherman.Potion Crafting Unlock Condition"_S)|| + mapName=="NPCs.Artificer.Enchant Crafting Unlock Condition"_S&& //When we beat the bonus chapter 2 fight, set the hub with a notification again. + !Unlock::IsUnlocked("NPCs.Artificer.Enchant Crafting Unlock Condition"_S)|| + mapName=="NPCs.Artificer.Enchant Crafting Unlock Condition"_S&& //When we beat the bonus chapter 3 fight, set the hub with a notification again. + !Unlock::IsUnlocked("NPCs.Artificer.Enchant Crafting Unlock Condition"_S) + ){ + State_OverworldMap::ResetConnectionPointsWithMapName("HUB"); + } STEAMUSERSTATS( datafile&areaUnlocks=DATA.GetProperty("Achievement.Area Unlocks"); for(auto&[key,size]:areaUnlocks){ diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 74ff4791..11192658 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_PATCH 5 -#define VERSION_BUILD 11357 +#define VERSION_BUILD 11361 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/VisualNovel.cpp b/Adventures in Lestoria/VisualNovel.cpp index 576dfe2a..bdc22454 100644 --- a/Adventures in Lestoria/VisualNovel.cpp +++ b/Adventures in Lestoria/VisualNovel.cpp @@ -243,7 +243,9 @@ void VisualNovel::ExecuteNextCommand(){ dialogFinishedCallbackFunc(); }else{ if(game->GetCurrentMapName()=="NPCs.Greg.Camp Notification Unlock Condition"_S&& - !Unlock::IsUnlocked("NPCs.Greg.Camp Notification Unlock Condition"_S))State_OverworldMap::ConnectionPointFromString("HUB").value()->ResetVisitedFlag(); + !Unlock::IsUnlocked("NPCs.Greg.Camp Notification Unlock Condition"_S)){ + State_OverworldMap::ResetConnectionPointsWithMapName("HUB"); + } Unlock::UnlockCurrentMap(); Menu::themeSelection=novel.prevTheme; GameState::ChangeState(States::OVERWORLD_MAP,0.5f); diff --git a/Adventures in Lestoria/assets/config/NPCs.txt b/Adventures in Lestoria/assets/config/NPCs.txt index 05f5d75e..2a5b866b 100644 --- a/Adventures in Lestoria/assets/config/NPCs.txt +++ b/Adventures in Lestoria/assets/config/NPCs.txt @@ -83,6 +83,8 @@ NPCs { Strategy = NPC + Enchant Crafting Unlock Condition = BOSS_3_B + #Size of each animation frame SheetFrameSize = 24,24 diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 50252ac0..d4a14a41 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ