diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj b/Adventures in Lestoria/Adventures in Lestoria.vcxproj index 9a5e5d07..a8b02d36 100644 --- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj +++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj @@ -162,7 +162,7 @@ _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp20 - C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria\discord-files;C:\Users\sigon\Documents\include;%(AdditionalIncludeDirectories) + C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria\discord-files;C:\Users\sigon\OneDrive\Documents\include;%(AdditionalIncludeDirectories) /MP8 %(AdditionalOptions) 4099;5030;4715;4172;4834 diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 2bc43e73..51c6b308 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -3078,10 +3078,10 @@ const uint8_t AiL::BossEncounterMobCount()const{ } -void AiL::GetAnyKeyPress(Key key){ +void AiL::GetAnyKeyRelease(Key key){ if(key!=0){ #pragma region New keyboard input binding listener - if(Menu::stack.back()==Menu::menus[NEW_INPUT]){ //We are requesting a brand new input. + if(Menu::IsMenuOpen()&&Menu::stack.back()==Menu::menus[NEW_INPUT]){ //We are requesting a brand new input. if(key==ESCAPE){ //If we hit escape we don't bother with setting the input and leave immediately. Menu::CloseMenu(); return; @@ -3089,11 +3089,18 @@ void AiL::GetAnyKeyPress(Key key){ using A=Attribute; if(InputGroup::menuNamesToInputGroups.count(Menu::menus[NEW_INPUT]->S(A::KEYBIND))){ InputGroup::menuNamesToInputGroups[Menu::menus[NEW_INPUT]->S(A::KEYBIND)]->SetNewPrimaryKeybind(Input{KEY,key}); + Menu::alreadyClicked=true; Menu::CloseMenu(); } } #pragma endregion + GameState::STATE->GetAnyKeyRelease(key); + } +} + +void AiL::GetAnyKeyPress(Key key){ + if(key!=0){ GameState::STATE->GetAnyKeyPress(key); } } \ No newline at end of file diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index 97767c0c..3f1fd988 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -154,7 +154,8 @@ public: bool OnUserCreate() override; bool OnUserUpdate(float fElapsedTime) override; bool OnUserDestroy() override; - void GetAnyKeyPress(Key key)override; + void GetAnyKeyPress(Key key)override final; + void GetAnyKeyRelease(Key key)override final; public: geom2d::rectNO_COLLISION={{0.f,0.f,},{0.f,0.f}}; TileTransformedView view; diff --git a/Adventures in Lestoria/GameState.cpp b/Adventures in Lestoria/GameState.cpp index c503040c..e1363484 100644 --- a/Adventures in Lestoria/GameState.cpp +++ b/Adventures in Lestoria/GameState.cpp @@ -79,4 +79,5 @@ void GameState::ChangeState(States::State newState,float fadeOutDuration){ GameState::~GameState(){} -void GameState::GetAnyKeyPress(Key k){} \ No newline at end of file +void GameState::GetAnyKeyPress(Key k){} +void GameState::GetAnyKeyRelease(Key k){} \ No newline at end of file diff --git a/Adventures in Lestoria/GameState.h b/Adventures in Lestoria/GameState.h index e5ccde7f..c07866db 100644 --- a/Adventures in Lestoria/GameState.h +++ b/Adventures in Lestoria/GameState.h @@ -68,5 +68,6 @@ public: virtual void OnUserUpdate(AiL*game)=0; virtual void Draw(AiL*game)=0; virtual void GetAnyKeyPress(Key k); + virtual void GetAnyKeyRelease(Key k); static void ChangeState(States::State newState,float fadeOutDuration=0); }; \ No newline at end of file diff --git a/Adventures in Lestoria/InputKeyboardWindow.cpp b/Adventures in Lestoria/InputKeyboardWindow.cpp index a978fd5e..687e9144 100644 --- a/Adventures in Lestoria/InputKeyboardWindow.cpp +++ b/Adventures in Lestoria/InputKeyboardWindow.cpp @@ -70,7 +70,9 @@ void Menu::InitializeKeyboardInputWindow(){ auto inputChangeButton=inputKeyboardWindow->ADD(std::format("Input_{}_{} Input Displayer",row,col),InputDisplayComponent)(geom2d::rect{vf2d{4,36}+vf2d{inputWindowWidth/2.f*col,row*12.f}+vf2d{inputWindowWidth/4.f,-1.f},vf2d{inputWindowWidth/4.f,11.f}},*InputGroup::menuNamesToInputGroups[inputDisplayName],InputType::KEY,[](MenuFuncData data){ Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)=true; - Menu::menus[NEW_INPUT]->S(A::KEYBIND)=data.component.lock()->S(A::KEYBIND); + std::string keybindName=data.component.lock()->S(A::KEYBIND); + Menu::menus[NEW_INPUT]->S(A::KEYBIND)=keybindName; + Component(NEW_INPUT,"New Keybind Label")->SetLabel(std::format("Press a new key for '{}'\n\nPress Esc to cancel.",keybindName)); Menu::OpenMenu(NEW_INPUT); return true; })END; diff --git a/Adventures in Lestoria/Key.cpp b/Adventures in Lestoria/Key.cpp index f4b6fa8f..33f55019 100644 --- a/Adventures in Lestoria/Key.cpp +++ b/Adventures in Lestoria/Key.cpp @@ -327,7 +327,7 @@ std::map,GenericKey::KeyInfo> GenericKey::keyLiteral={ {{KEY, H},{"H"}}, {{KEY, I},{"I"}}, {{KEY, J},{"J"}}, - {{KEY, K},{"L"}}, + {{KEY, K},{"K"}}, {{KEY, L},{"L"}}, {{KEY, M},{"M"}}, {{KEY, N},{"N"}}, @@ -539,9 +539,16 @@ const InputEngageGroup InputEngageGroup::operator=(const InputEngageGroup&rhs){ void InputGroup::RemovePrimaryKeybind(InputType type){ - keyOrder.erase(keyOrder.begin()); + auto primaryInputIt=std::find_if(keyOrder.begin(),keyOrder.end(),[&](Input&input){return input.GetType()==type;}); + + if(primaryInputIt!=keyOrder.end()){ + Input&primaryInput=*primaryInputIt; + keys.erase(primaryInput); + keyOrder.erase(primaryInputIt); + }else ERR(std::format("WARNING! Could not find a valid primary input of type {}! THIS SHOULD NOT BE HAPPENING!",int(type))); } void InputGroup::AddPrimaryKeybind(Input key){ + keys.insert(key); keyOrder.insert(keyOrder.begin(),{key.GetType(),key.key}); } void InputGroup::SetNewPrimaryKeybind(Input key){ diff --git a/Adventures in Lestoria/Menu.h b/Adventures in Lestoria/Menu.h index 3fa673b4..819e1e95 100644 --- a/Adventures in Lestoria/Menu.h +++ b/Adventures in Lestoria/Menu.h @@ -200,8 +200,6 @@ public: void SetSelection(std::variant>button,const bool reset=false); // Use the reset parameter when a window is opening up, as this will cause the window now to scroll to its previous target. const std::weak_ptrGetSelection()const; const std::weak_ptrGetKeySelection()const; - void IncreaseSelectionIndex(const float val); - void DecreaseSelectionIndex(const float val); private: Menu(vf2d pos,vf2d size); static MenuType lastMenuTypeCreated; diff --git a/Adventures in Lestoria/State_OverworldMap.cpp b/Adventures in Lestoria/State_OverworldMap.cpp index 0632e1d2..f63dff1f 100644 --- a/Adventures in Lestoria/State_OverworldMap.cpp +++ b/Adventures in Lestoria/State_OverworldMap.cpp @@ -253,6 +253,4 @@ void State_OverworldMap::ResetConnectionPoints(){ for(ConnectionPoint&cp:connections){ cp.visited=false; } -} - -void State_OverworldMap::GetAnyKeyPress(Key key){} \ No newline at end of file +} \ No newline at end of file diff --git a/Adventures in Lestoria/State_OverworldMap.h b/Adventures in Lestoria/State_OverworldMap.h index d361ab16..ad9a46a0 100644 --- a/Adventures in Lestoria/State_OverworldMap.h +++ b/Adventures in Lestoria/State_OverworldMap.h @@ -59,5 +59,4 @@ public: virtual void Draw(AiL*game)override final; static void StartLevel(); static void UpdateCurrentConnectionPoint(const ConnectionPoint&connection); - virtual void GetAnyKeyPress(Key key)override final; }; \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 588da469..49ddad6e 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -30,7 +30,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 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 +Portions of this software are copyright ???? 2024 The FreeType Project (www.freetype.org). Please see LICENSE_FT.txt for more information. All rights reserved. */ @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 6836 +#define VERSION_BUILD 6852 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/olcPixelGameEngine.h b/Adventures in Lestoria/olcPixelGameEngine.h index 1de521c0..e9269758 100644 --- a/Adventures in Lestoria/olcPixelGameEngine.h +++ b/Adventures in Lestoria/olcPixelGameEngine.h @@ -995,6 +995,7 @@ namespace olc // Called once on application termination, so you can be one clean coder virtual bool OnUserDestroy(); virtual void GetAnyKeyPress(Key key); + virtual void GetAnyKeyRelease(Key key); // Called when a text entry is confirmed with "enter" key virtual void OnTextEntryComplete(const std::string& sText); @@ -4416,6 +4417,8 @@ namespace olc void PixelGameEngine::GetAnyKeyPress(Key key) { } + void PixelGameEngine::GetAnyKeyRelease(Key key) + { } void PixelGameEngine::OnTextEntryComplete(const std::string& sText) { UNUSED(sText); } bool PixelGameEngine::OnConsoleCommand(const std::string& sCommand) { UNUSED(sCommand); return false; } @@ -4643,12 +4646,13 @@ namespace olc { pKeys[i].bPressed = !pKeys[i].bHeld; pKeys[i].bHeld = true; - GetAnyKeyPress(Key(i)); + if(pKeys==pKeyboardState)GetAnyKeyPress(Key(i)); //Only produce an event when it's for the keyboard. } else { pKeys[i].bReleased = true; pKeys[i].bHeld = false; + if(pKeys==pKeyboardState)GetAnyKeyRelease(Key(i)); //Only produce an event when it's for the keyboard. } } pStateOld[i] = pStateNew[i];