diff --git a/.gitignore b/.gitignore index 9cee0b3d..f44f6485 100644 --- a/.gitignore +++ b/.gitignore @@ -425,3 +425,4 @@ desktop.ini /Adventures in Lestoria Tests/x64/Unit Testing /x64/Unit Testing /Adventures in Lestoria/assets/2.10 +/Adventures in Lestoria/assets/items/Bird_s Treasure.png diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj b/Adventures in Lestoria/Adventures in Lestoria.vcxproj index cb4ccfee..610ab9f7 100644 --- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj +++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj @@ -218,7 +218,7 @@ _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp20 - C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria\steam;C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria\discord-files;C:\Users\sigon\OneDrive\Documents\include;%(AdditionalIncludeDirectories) + C:\Users\LabUser\source\repos\AdventuresInLestoria\Adventures in Lestoria\steam;C:\Users\LabUser\source\repos\AdventuresInLestoria\Adventures in Lestoria\discord-files;C:\Users\LabUser\Documents\include;C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria\steam;C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria\discord-files;C:\Users\sigon\OneDrive\Documents\include;%(AdditionalIncludeDirectories) /MP20 %(AdditionalOptions) 4099;5030;4715;4172;4834 true @@ -226,7 +226,7 @@ Console true - C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria;%(AdditionalLibraryDirectories) + C:\Users\LabUser\source\repos\AdventuresInLestoria\Adventures in Lestoria;C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria;%(AdditionalLibraryDirectories) discord_game_sdk.dll.lib;freetype.lib;steam_api64.lib;$(CoreLibraryDependencies);%(AdditionalDependencies); @@ -622,6 +622,7 @@ + @@ -1054,6 +1055,7 @@ + diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters b/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters index 94a086eb..1339d862 100644 --- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters +++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters @@ -669,6 +669,9 @@ Header Files + + Header Files\State + @@ -1154,8 +1157,8 @@ Source Files\Bullet Types - - Configurations\Story + + Source Files\Game States diff --git a/Adventures in Lestoria/GameState.cpp b/Adventures in Lestoria/GameState.cpp index 9d21e155..c43978c5 100644 --- a/Adventures in Lestoria/GameState.cpp +++ b/Adventures in Lestoria/GameState.cpp @@ -42,7 +42,8 @@ All rights reserved. #include "State_LevelComplete.h" #include "State_Story.h" #include "State_GameHub.h" -#include "State_Death.h"; +#include "State_Death.h" +#include "State_Dialog.h" INCLUDE_game @@ -56,6 +57,7 @@ void GameState::Initialize(){ NEW_STATE(States::STORY,State_Story); NEW_STATE(States::GAME_HUB,State_GameHub); NEW_STATE(States::DEATH,State_Death); + NEW_STATE(States::DIALOG,State_Dialog); } void GameState::_ChangeState(States::State newState){ diff --git a/Adventures in Lestoria/GameState.h b/Adventures in Lestoria/GameState.h index 86ed8479..8a246f91 100644 --- a/Adventures in Lestoria/GameState.h +++ b/Adventures in Lestoria/GameState.h @@ -51,6 +51,7 @@ namespace States{ MAIN_MENU, LEVEL_COMPLETE, STORY, + DIALOG, KEYBIND, DEATH, }; diff --git a/Adventures in Lestoria/State_Dialog.cpp b/Adventures in Lestoria/State_Dialog.cpp new file mode 100644 index 00000000..97d073b8 --- /dev/null +++ b/Adventures in Lestoria/State_Dialog.cpp @@ -0,0 +1,55 @@ +#pragma region License +/* +License (OLC-3) +~~~~~~~~~~~~~~~ + +Copyright 2024 Joshua Sigona + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions or derivations of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions or derivative works in binary form must reproduce the above +copyright notice. This list of conditions and the following disclaimer must be +reproduced in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may +be used to endorse or promote products derived from this software without specific +prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +Portions of this software are copyright © 2024 The FreeType +Project (www.freetype.org). Please see LICENSE_FT.txt for more information. +All rights reserved. +*/ +#pragma endregion +#include "State_Dialog.h" +#include "VisualNovel.h" +#include "Menu.h" +#include "AdventuresInLestoria.h" + +void State_Dialog::OnStateChange(GameState*prevState){ + Menu::CloseAllMenus(); +}; +void State_Dialog::OnLevelLoad(){} +void State_Dialog::OnUserUpdate(AiL*game){ + GameState::states[States::GAME_RUN]->OnUserUpdate(game); + VisualNovel::novel.Update(); + game->ClearTimedOutGarbage(); +}; +void State_Dialog::Draw(AiL*game){ + GameState::states[States::GAME_RUN]->Draw(game); + VisualNovel::novel.Draw(0U); +}; \ No newline at end of file diff --git a/Adventures in Lestoria/State_Dialog.h b/Adventures in Lestoria/State_Dialog.h new file mode 100644 index 00000000..9fbf78b4 --- /dev/null +++ b/Adventures in Lestoria/State_Dialog.h @@ -0,0 +1,46 @@ +#pragma region License +/* +License (OLC-3) +~~~~~~~~~~~~~~~ + +Copyright 2024 Joshua Sigona + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions or derivations of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions or derivative works in binary form must reproduce the above +copyright notice. This list of conditions and the following disclaimer must be +reproduced in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may +be used to endorse or promote products derived from this software without specific +prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +Portions of this software are copyright © 2024 The FreeType +Project (www.freetype.org). Please see LICENSE_FT.txt for more information. +All rights reserved. +*/ +#pragma endregion +#pragma once +#include "GameState.h" + +class State_Dialog:public GameState { + virtual void OnStateChange(GameState*prevState)override final; + virtual void OnUserUpdate(AiL*game)override final; + virtual void Draw(AiL*game)override final; + virtual void OnLevelLoad()override final; +}; \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 0f7f8987..16d10478 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 3 -#define VERSION_BUILD 10399 +#define VERSION_BUILD 10402 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/VisualNovel.cpp b/Adventures in Lestoria/VisualNovel.cpp index e1f8c095..f563a7e2 100644 --- a/Adventures in Lestoria/VisualNovel.cpp +++ b/Adventures in Lestoria/VisualNovel.cpp @@ -184,14 +184,17 @@ void VisualNovel::Initialize(){ storyLevelData.SetInitialized(); }; +void VisualNovel::Reset(){ + activeText=U""; + leftCharacters.clear(); + rightCharacters.clear(); + backgroundFilename=novel.prevBackgroundFilename=""; + commands.clear(); + commandIndex=0; +} void VisualNovel::LoadVisualNovel(std::string storyLevelName){ novel.storyLevel=storyLevelName; - novel.activeText=U""; - novel.leftCharacters.clear(); - novel.rightCharacters.clear(); - novel.backgroundFilename=novel.prevBackgroundFilename=""; - novel.commands.clear(); - novel.commandIndex=0; + novel.Reset(); for(std::unique_ptr&command:storyLevelData.at(storyLevelName)){ novel.commands.push_back(command.get()); } @@ -219,25 +222,30 @@ void VisualNovel::ExecuteNextCommand(){ commandIndex++; commands[size_t(commandIndex-1)]->Execute(novel); }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::UnlockCurrentMap(); - Menu::themeSelection=novel.prevTheme; - GameState::ChangeState(States::OVERWORLD_MAP,0.5f); + if(GameState::STATE==GameState::states[States::DIALOG]){ + Reset(); + GameState::STATE=GameState::states[States::GAME_RUN]; + }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::UnlockCurrentMap(); + Menu::themeSelection=novel.prevTheme; + GameState::ChangeState(States::OVERWORLD_MAP,0.5f); + } } } -void VisualNovel::Draw(){ +void VisualNovel::Draw(const uint8_t backgroundAlpha){ if(backgroundFilename!=""){ - float alpha=1; + float alpha=backgroundAlpha/255.f; if(transitionTime>0){ - alpha=util::lerp(0,1,1-(transitionTime/maxTransitionTime)); + alpha=alpha*util::lerp(0,1,1-(transitionTime/maxTransitionTime)); } if(prevBackgroundFilename!=""){ - game->DrawDecal({0,-prevBackgroundScrollAmt},GFX["story_background_image_location"_S+prevBackgroundFilename].Decal()); + game->DrawDecal({0,-prevBackgroundScrollAmt},GFX["story_background_image_location"_S+prevBackgroundFilename].Decal(),{1.f,1.f},{255,255,255,backgroundAlpha}); } game->DrawDecal({0,-backgroundScrollAmt},GFX["story_background_image_location"_S+backgroundFilename].Decal(),{1,1},{255,255,255,uint8_t(255*alpha)}); }else{ - game->FillRectDecal({0,0},game->GetScreenSize()); + game->FillRectDecal({0,0},game->GetScreenSize(),{255,255,255,backgroundAlpha}); } for(int i=leftCharacters.size()-1;i>=0;i--){ //Start 72 from the bottom. diff --git a/Adventures in Lestoria/VisualNovel.h b/Adventures in Lestoria/VisualNovel.h index da46f485..a8334045 100644 --- a/Adventures in Lestoria/VisualNovel.h +++ b/Adventures in Lestoria/VisualNovel.h @@ -142,6 +142,7 @@ public: class VisualNovel{ friend class State_Story; + friend class State_Dialog; friend class AiL; friend class Command; friend class LocationCommand; @@ -154,7 +155,7 @@ class VisualNovel{ friend class AudioPitchCommand; std::string storyLevel; std::u32string speakerDisplayName=U""; - std::u32string actualSpeakerName=U""; + std::u32string actualSpeakerName=U""; std::u32string activeText; std::vectorleftCharacters; std::vectorrightCharacters; @@ -181,6 +182,7 @@ private: static VisualNovel novel; VisualNovel(); + void Reset(); public: VisualNovel(VisualNovel&)=delete; VisualNovel(VisualNovel&&)=delete; @@ -188,6 +190,6 @@ public: static void LoadVisualNovel(std::string storyLevelName); void ExecuteNextCommand(); void Update(); - void Draw(); + void Draw(const uint8_t backgroundAlpha=255U); std::string GetCharacterImage(std::u32string name); }; \ No newline at end of file