diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index fa9b3c98..8f3675c9 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -108,13 +108,17 @@ InputGroup AiL::KEY_DOWN; InputGroup AiL::KEY_ATTACK; InputGroup AiL::KEY_CONFIRM; InputGroup AiL::KEY_MENU; -InputGroup AiL::KEY_SCROLLUP; -InputGroup AiL::KEY_SCROLLDOWN; InputGroup AiL::KEY_BACK; InputGroup AiL::KEY_START; InputGroup AiL::KEY_SELECT; InputGroup AiL::KEY_UNEQUIP; +InputGroup AiL::KEY_SCROLLDOWN; +InputGroup AiL::KEY_SCROLLUP; +InputGroup AiL::KEY_SCROLLLEFT; +InputGroup AiL::KEY_SCROLLRIGHT; +InputGroup AiL::KEY_SCROLLHORZ; +InputGroup AiL::KEY_SCROLLVERT; InputGroup AiL::KEY_SCROLL; InputGroup AiL::KEY_CHANGE_LOADOUT; @@ -2505,8 +2509,19 @@ void AiL::InitializeDefaultKeybinds(){ KEY_SELECT.AddKeybind({KEY,ESCAPE}); KEY_SELECT.AddKeybind({CONTROLLER,static_cast(GPButtons::SELECT)}); - KEY_SCROLL.AddKeybind({ANALOG,static_cast(GPAxes::LY)}); - KEY_SCROLL.AddKeybind({ANALOG,static_cast(GPAxes::RY)}); + KEY_SCROLLLEFT.AddKeybind({ANALOG,static_cast(GPAxes::LX)}); + KEY_SCROLLLEFT.AddKeybind({ANALOG,static_cast(GPAxes::RX)}); + KEY_SCROLLRIGHT.AddKeybind({ANALOG,static_cast(GPAxes::LX)}); + KEY_SCROLLRIGHT.AddKeybind({ANALOG,static_cast(GPAxes::RX)}); + KEY_SCROLLUP.AddKeybind({ANALOG,static_cast(GPAxes::LY)}); + KEY_SCROLLUP.AddKeybind({ANALOG,static_cast(GPAxes::RY)}); + KEY_SCROLLDOWN.AddKeybind({ANALOG,static_cast(GPAxes::LY)}); + KEY_SCROLLDOWN.AddKeybind({ANALOG,static_cast(GPAxes::RY)}); + KEY_SCROLLVERT.AddKeybind({ANALOG,static_cast(GPAxes::LY)}); + KEY_SCROLLVERT.AddKeybind({ANALOG,static_cast(GPAxes::RY)}); + KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast(GPAxes::LX)}); + KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast(GPAxes::RX)}); + KEY_SCROLL.AddKeybind({ANALOG,static_cast(GPAxes::ALL)}); KEY_UNEQUIP.AddKeybind({KEY,R}); KEY_UNEQUIP.AddKeybind({CONTROLLER,static_cast(GPButtons::FACE_U)}); diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index 3f1fd988..52482b79 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -73,8 +73,6 @@ class AiL : public olc::PixelGameEngine SplashScreen splash; public: Pathfinding pathfinder; - static InputGroup KEY_SCROLLUP; - static InputGroup KEY_SCROLLDOWN; static InputGroup KEY_BACK; static InputGroup KEY_CONFIRM; static InputGroup KEY_ATTACK; @@ -88,6 +86,12 @@ public: static InputGroup KEY_START; static InputGroup KEY_SELECT; + static InputGroup KEY_SCROLLDOWN; + static InputGroup KEY_SCROLLUP; + static InputGroup KEY_SCROLLLEFT; + static InputGroup KEY_SCROLLRIGHT; + static InputGroup KEY_SCROLLHORZ; + static InputGroup KEY_SCROLLVERT; static InputGroup KEY_SCROLL; static InputGroup KEY_CHANGE_LOADOUT; diff --git a/Adventures in Lestoria/InventoryConsumableWindow.cpp b/Adventures in Lestoria/InventoryConsumableWindow.cpp index 462cda9e..00675c36 100644 --- a/Adventures in Lestoria/InventoryConsumableWindow.cpp +++ b/Adventures in Lestoria/InventoryConsumableWindow.cpp @@ -86,18 +86,6 @@ void Menu::InitializeConsumableInventoryWindow(){ auto okButton=inventoryWindow->ADD("OK Button",MenuComponent)(geom2d::rect{{windowSize.x/2-24,173.f},{48,12}},"Ok",[](MenuFuncData data){Menu::CloseMenu();return true;})END; - #pragma region ScrollWindow macro lambda - #define ScrollWindow(amount) \ - [](MenuType type){ \ - auto scrollWindow=Component(type,"inventory"); \ - scrollWindow->Scroll(amount); \ - int invWidth=int((scrollWindow->rect.size.x-12)/(float(scrollWindow->options.size.x)+scrollWindow->options.padding)); /*The inventory width determines how many items to skip at a time.*/ \ - scrollWindow->SetSelectionSkipIncrement(invWidth); \ - float scrollAmt=amount*game->GetElapsedTime()*"Interface.AnalogScrollSpeed"_F; \ - scrollWindow->IncreaseSelectionIndex(scrollAmt/24.f); \ - } - #pragma endregion - inventoryWindow->SetupKeyboardNavigation( [](MenuType type,Data&returnData){ //On Open //Try to find the component that matches the loadout item we have on us. @@ -123,9 +111,7 @@ void Menu::InitializeConsumableInventoryWindow(){ {game->KEY_BACK,{"Back",[](MenuType type){ Menu::CloseMenu(); }}}, - {{game->KEY_SCROLL,Analog},{"Scroll",ScrollWindow(game->KEY_SCROLL.Analog())}}, - {{game->KEY_SCROLLUP,Held},{"Scroll Up",ScrollWindow(-1.0f)}}, - {{game->KEY_SCROLLDOWN,Held},{"Scroll Down",ScrollWindow(1.0f)}}, + {{game->KEY_SCROLLVERT,Analog},{"Scroll",[](MenuType type){}}}, } ,{ //Button Navigation Rules {"OK Button",{ diff --git a/Adventures in Lestoria/Key.cpp b/Adventures in Lestoria/Key.cpp index 9c7718ef..11600ce8 100644 --- a/Adventures in Lestoria/Key.cpp +++ b/Adventures in Lestoria/Key.cpp @@ -260,6 +260,34 @@ const float InputGroup::Analog()const{ return 0.f; } +const float InputGroup::AnalogDAS(){ + for(Input input:keys){ + float analogVal=input.Analog(); + if(analogVal!=0.f&&initialHoldDownTime==0.f){ + initialHoldDownTime="Interface.InitialScrollDelay"_F; + return analogVal; + }else + if(analogVal!=0.f&&initialHoldDownTime>0.f){ + initialHoldDownTime-=game->GetElapsedTime(); + if(initialHoldDownTime<=0.f){ + holdDownTime="Interface.ScrollDelay"_F; + return analogVal; + } + return 0.f; + }else + if(analogVal!=0.f&&holdDownTime>0.f){ + holdDownTime-=game->GetElapsedTime(); + if(holdDownTime<=0.f){ + holdDownTime="Interface.ScrollDelay"_F; + return analogVal; + } + return 0.f; + } + } + initialHoldDownTime=holdDownTime=0.f; + return 0.f; +} + std::string InputGroup::GetDisplayName(){ std::string combinationDisplay=""; for(Input input:keys){ @@ -480,6 +508,7 @@ std::map,GenericKey::KeyInfo> GenericKey::keyLiteral={ {{ANALOG, static_cast(GPAxes::TR)},{"Right Trigger","themes/button_r2.png"}}, {{ANALOG, static_cast(GPAxes::DX)},{"Right/Left","themes/button_analogstick_horz.png"}}, {{ANALOG, static_cast(GPAxes::DY)},{"Up/Down","themes/button_analogstick_vert.png"}}, + {{ANALOG, static_cast(GPAxes::ALL)},{"Analog Stick","themes/button_analogstick.png"}}, }; void Input::SetUsingGamepad(const bool usingGamepad){ diff --git a/Adventures in Lestoria/Key.h b/Adventures in Lestoria/Key.h index 4202779e..09b88d95 100644 --- a/Adventures in Lestoria/Key.h +++ b/Adventures in Lestoria/Key.h @@ -111,6 +111,7 @@ public: const bool Held()const; const bool Released(); const float Analog()const; + const float AnalogDAS(); std::string GetDisplayName(); //Draws an input display with accompanying text centered at given position. void DrawInput(const std::variantrenderer,const vf2d pos,const std::string_view displayText,const uint8_t alpha)const; diff --git a/Adventures in Lestoria/LoadGameWindow.cpp b/Adventures in Lestoria/LoadGameWindow.cpp index 2e0b03f9..0e1ee4e6 100644 --- a/Adventures in Lestoria/LoadGameWindow.cpp +++ b/Adventures in Lestoria/LoadGameWindow.cpp @@ -81,17 +81,6 @@ void Menu::InitializeLoadGameWindow(){ onlineCharacterTab->SetSelectionType(HIGHLIGHT); #endif - #pragma region ScrollWindow macro lambda - #define ScrollWindow(amount) \ - [](MenuType type){ \ - auto scrollWindow=Component(type,"Game Files List"); \ - scrollWindow->Scroll(amount); \ - float scrollAmt=amount*game->GetElapsedTime()*"Interface.AnalogScrollSpeed"_F;\ - /*Height of these buttons is 48.*/ \ - scrollWindow->IncreaseSelectionIndex(scrollAmt/48.f); \ - } - #pragma endregion - #pragma region Keyboard Navigation Rules loadGameWindow->SetupKeyboardNavigation( [](MenuType type,Data&returnData){ //On Open @@ -109,9 +98,7 @@ void Menu::InitializeLoadGameWindow(){ {{game->KEY_BACK},{"Back to Title Screen",[](MenuType type){ Component(type,"Go Back Button")->Click(); }}}, - {{game->KEY_SCROLL,Analog},{"Scroll",ScrollWindow(game->KEY_SCROLL.Analog())}}, - {{game->KEY_SCROLLUP,Held},{"Scroll Up",ScrollWindow(-1.0f)}}, - {{game->KEY_SCROLLDOWN,Held},{"Scroll Down",ScrollWindow(1.0f)}}, + {{game->KEY_SCROLLVERT,Analog},{"Scroll",[](MenuType type){}}}, } ,{ //Button Navigation Rules {"Game Files List",{ diff --git a/Adventures in Lestoria/Menu.cpp b/Adventures in Lestoria/Menu.cpp index 681283e1..483addb1 100644 --- a/Adventures in Lestoria/Menu.cpp +++ b/Adventures in Lestoria/Menu.cpp @@ -342,7 +342,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){ if(navigationGroups.count(selectionButtonName)){ Navigation nav=navigationGroups[selectionButtonName]; - if(game->KEY_UP.PressedDAS()){ + if(game->KEY_UP.PressedDAS()||game->KEY_SCROLLUP.AnalogDAS()<-0.2f){ SetMouseNavigation(false); if(std::holds_alternative(nav.up)&&std::get(nav.up).length()>0)SetSelection(std::string_view(std::get(nav.up))); else @@ -352,7 +352,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){ SetSelection(returnData); } } - if(game->KEY_DOWN.PressedDAS()){ + if(game->KEY_DOWN.PressedDAS()||game->KEY_SCROLLDOWN.AnalogDAS()>0.2f){ SetMouseNavigation(false); if(std::holds_alternative(nav.down)&&std::get(nav.down).length()>0)SetSelection(std::string_view(std::get(nav.down))); else @@ -362,7 +362,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){ SetSelection(returnData); } } - if(game->KEY_LEFT.PressedDAS()){ + if(game->KEY_LEFT.PressedDAS()||game->KEY_SCROLLLEFT.AnalogDAS()<-0.2f){ SetMouseNavigation(false); if(std::holds_alternative(nav.left)&&std::get(nav.left).length()>0)SetSelection(std::string_view(std::get(nav.left))); else @@ -372,7 +372,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){ SetSelection(returnData); } } - if(game->KEY_RIGHT.PressedDAS()){ + if(game->KEY_RIGHT.PressedDAS()||game->KEY_SCROLLRIGHT.AnalogDAS()>0.2f){ SetMouseNavigation(false); if(std::holds_alternative(nav.right)&&std::get(nav.right).length()>0)SetSelection(std::string_view(std::get(nav.right))); else @@ -387,7 +387,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){ if(game->KEY_UP.Released()||game->KEY_RIGHT.Released()||game->KEY_LEFT.Released()||game->KEY_DOWN.Released()|| game->KEY_BACK.Released()||game->KEY_CONFIRM.Released()||game->KEY_START.Released()||game->KEY_SELECT.Released()|| - game->KEY_SCROLLDOWN.Released()||game->KEY_SCROLLUP.Released()||game->KEY_SCROLL.Analog()!=0.f){ + game->KEY_SCROLLDOWN.Released()||game->KEY_SCROLLUP.Released()||game->KEY_SCROLLVERT.Analog()!=0.f){ SetMouseNavigation(game->GetMouse(Mouse::LEFT).bReleased||game->GetMouse(Mouse::RIGHT).bReleased||game->GetMouse(Mouse::MIDDLE).bReleased); //If a click occurs we use mouse controls. buttonHoldTime=0; } diff --git a/Adventures in Lestoria/OverworldMapLevelWindow.cpp b/Adventures in Lestoria/OverworldMapLevelWindow.cpp index 40001f49..3c30e4a1 100644 --- a/Adventures in Lestoria/OverworldMapLevelWindow.cpp +++ b/Adventures in Lestoria/OverworldMapLevelWindow.cpp @@ -74,8 +74,8 @@ void Menu::InitializeOverworldMapLevelWindow(){ {{game->KEY_CHANGE_LOADOUT},{"Change Loadout",[](MenuType type){ Component(type,"Change Loadout Button")->Click(); }}}, - {{game->KEY_SCROLL,Analog},{"Scroll Encounters",[](MenuType type){ - Component(type,"Spawns List")->Scroll(game->KEY_SCROLL.Analog()); + {{game->KEY_SCROLLVERT,Analog},{"Scroll Encounters",[](MenuType type){ + Component(type,"Spawns List")->Scroll(game->KEY_SCROLLVERT.Analog()); }}}, {{game->KEY_SCROLLUP,Held},{"",[](MenuType type){ Component(type,"Spawns List")->Scroll(1.f); diff --git a/Adventures in Lestoria/ScrollableWindowComponent.h b/Adventures in Lestoria/ScrollableWindowComponent.h index d5a63b7c..90aad62e 100644 --- a/Adventures in Lestoria/ScrollableWindowComponent.h +++ b/Adventures in Lestoria/ScrollableWindowComponent.h @@ -105,16 +105,6 @@ public: return geom2d::overlaps(geom2d::rect{Menu::menus[parentMenu]->pos+rect.pos,rect.size},game->GetMousePos())&& //Make sure the mouse is inside the parent window component first.... geom2d::overlaps(geom2d::rect{Menu::menus[parentMenu]->pos+rect.pos+child->rect.pos,child->rect.size},game->GetMousePos()); } - - inline void SetSelectionSkipIncrement(const int selectionSkipIncrement){ - this->selectionSkipIncrement=selectionSkipIncrement; - } - - inline void IncreaseSelectionIndex(const float val){ - float prevIndex=selectionIndex/selectionSkipIncrement; - selectionIndex=std::clamp(selectionIndex+val,0.f,float(components.size()-1)); - if(size_t(prevIndex)!=size_t(selectionIndex/selectionSkipIncrement)){Menu::menus[parentMenu]->SetSelection(components[size_t(selectionIndex)],false);} - } protected: virtual inline vf2d GetScrollAmount()const{ return scrollOffset; diff --git a/Adventures in Lestoria/State_MainMenu.cpp b/Adventures in Lestoria/State_MainMenu.cpp index b6d2e7ee..f8a8bf8a 100644 --- a/Adventures in Lestoria/State_MainMenu.cpp +++ b/Adventures in Lestoria/State_MainMenu.cpp @@ -56,4 +56,5 @@ void State_MainMenu::OnUserUpdate(AiL*game){ }; void State_MainMenu::Draw(AiL*game){ TitleScreen::Draw(); + game->DrawOGStringDecal({0,0},"DOWN: "+std::to_string(game->KEY_SCROLLVERT.Analog())); }; \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 07b2de9e..164fc87f 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 6923 +#define VERSION_BUILD 6933 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/themes/button_analogstick.png b/Adventures in Lestoria/assets/themes/button_analogstick.png new file mode 100644 index 00000000..c157ac07 Binary files /dev/null and b/Adventures in Lestoria/assets/themes/button_analogstick.png differ diff --git a/Adventures in Lestoria/olcPGEX_Gamepad.h b/Adventures in Lestoria/olcPGEX_Gamepad.h index aa6a68f1..916359f8 100644 --- a/Adventures in Lestoria/olcPGEX_Gamepad.h +++ b/Adventures in Lestoria/olcPGEX_Gamepad.h @@ -151,6 +151,7 @@ namespace olc { TR = 3, DX = 6, DY = 7, + ALL = 8, //This does not actually do anything, but is useful for detecting an icon for any analog stick control! }; #pragma endregion diff --git a/Adventures in Lestoria/olcPixelGameEngine.h b/Adventures in Lestoria/olcPixelGameEngine.h index e9269758..c3345a3d 100644 --- a/Adventures in Lestoria/olcPixelGameEngine.h +++ b/Adventures in Lestoria/olcPixelGameEngine.h @@ -1162,6 +1162,7 @@ namespace olc void DrawPartialRotatedDecal(const olc::vf2d& pos, olc::Decal* decal, const float fAngle, const olc::vf2d& center, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::vf2d& scale = { 1.0f, 1.0f }, const olc::Pixel& tint = olc::WHITE); // Draws a multiline string as a decal, with tiniting and scaling void DrawStringDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f },const float width=std::numeric_limits::max(),const bool disableDynamicScaling=false); + void DrawOGStringDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }); void DrawStringDecal(Font&font, const olc::vf2d& pos, const std::u32string& sText, const Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }); void DrawStringPropDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }, const float width=std::numeric_limits::max(),const bool disableDynamicScaling=false); void DrawShadowStringDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col = olc::WHITE, const Pixel shadowCol = olc::BLACK, const olc::vf2d& scale = { 1.0f, 1.0f },const float width=std::numeric_limits::max(),const float shadowSizeFactor=1,const bool disableDynamicScaling=false); @@ -3375,6 +3376,29 @@ namespace olc void PixelGameEngine::DrawPartialWarpedDecal(olc::Decal* decal, const olc::vf2d(&pos)[4], const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint) { DrawPartialWarpedDecal(decal, &pos[0], source_pos, source_size, tint); } + void PixelGameEngine::DrawOGStringDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col, const olc::vf2d& scale) + { + olc::vf2d spos = { 0.0f, 0.0f }; + for (auto c : sText) + { + if (c == '\n') + { + spos.x = 0; spos.y += 8.0f * scale.y; + } + else if (c == '\t') + { + spos.x += 8.0f * float(nTabSizeInSpaces) * scale.x; + } + else + { + int32_t ox = (c - 32) % 16; + int32_t oy = (c - 32) / 16; + DrawPartialDecal(pos + spos, fontRenderable.Decal(), {float(ox) * 8.0f, float(oy) * 8.0f}, {8.0f, 8.0f}, scale, col); + spos.x += 8.0f * scale.x; + } + } + } + void PixelGameEngine::DrawStringDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col, const olc::vf2d& scale,const float width,const bool disableDynamicScaling) { struct DecalData{