diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 0523ac96..75686487 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -104,6 +104,8 @@ InputGroup AiL::KEY_BACK; InputGroup AiL::KEY_START; InputGroup AiL::KEY_SELECT; +InputGroup AiL::KEY_SCROLL; + #ifndef __EMSCRIPTEN__ ::discord::Core*Discord{}; #endif @@ -172,6 +174,9 @@ AiL::AiL() std::string AUDIO_CONFIG = CONFIG_PATH + "audio_config"_S; utils::datafile::Read(DATA,AUDIO_CONFIG); + std::string INTERFACE_CONFIG = CONFIG_PATH + "interface_config"_S; + utils::datafile::Read(DATA,INTERFACE_CONFIG); + std::string ENVIRONMENTAL_AUDIO_CONFIG = CONFIG_PATH + "environmental_audio_config"_S; utils::datafile::Read(DATA,ENVIRONMENTAL_AUDIO_CONFIG); @@ -2402,6 +2407,9 @@ void AiL::InitializeDefaultKeybinds(){ KEY_START.AddKeybind({CONTROLLER,static_cast(GPButtons::START)}); 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)}); } void AiL::SetBossNameDisplay(std::string name,float time){ diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index 52bbe519..8c936881 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -87,6 +87,8 @@ public: static InputGroup KEY_START; static InputGroup KEY_SELECT; + static InputGroup KEY_SCROLL; + static float SIZE_CHANGE_SPEED; double levelTime; Camera2D camera; diff --git a/Adventures in Lestoria/Key.cpp b/Adventures in Lestoria/Key.cpp index 516789c2..502e1b5e 100644 --- a/Adventures in Lestoria/Key.cpp +++ b/Adventures in Lestoria/Key.cpp @@ -125,6 +125,27 @@ bool Input::Released(){ return false; } +float Input::Analog(){ + if(!game->IsFocused())return false; + switch(type){ + case ANALOG:{ + for(GamePad*gamepad:GamePad::getGamepads()){ + if(gamepad->stillConnected){ + float axisVal=gamepad->getAxis(static_cast(key)); + if(axisVal!=0.f){ + usingGamepad=true; + return axisVal; + } + } + } + }break; + default:{ + ERR("Invalid Control Scheme detected for analog controls! We shouldn't be here!! Type is "<KEY_BACK,{"Back to Title Screen",[](MenuType type){ Component(type,"Go Back Button")->Click(); }}}, + {game->KEY_SCROLL,{"Scroll Up/Down",[](MenuType type){ + auto&scrollWindow=Component(type,"Game Files List"); + scrollWindow->SetScrollAmount(scrollWindow->GetScrollAmount()+game->KEY_SCROLL.Analog()*game->GetElapsedTime()*"Interface.AnalogScrollSpeed"_F); + }}}, } ,{ //Button Navigation Rules {"Game Files List",{ diff --git a/Adventures in Lestoria/assets/config/Interface.txt b/Adventures in Lestoria/assets/config/Interface.txt new file mode 100644 index 00000000..b2d8f704 --- /dev/null +++ b/Adventures in Lestoria/assets/config/Interface.txt @@ -0,0 +1,8 @@ +Interface +{ + # In pixels/sec + AnalogScrollSpeed = 120 + + # The size of each side of the 9-patch menu sprite. + 9PatchSize = 24,24 +} \ No newline at end of file diff --git a/Adventures in Lestoria/assets/config/configuration.txt b/Adventures in Lestoria/assets/config/configuration.txt index 3412113e..412aec27 100644 --- a/Adventures in Lestoria/assets/config/configuration.txt +++ b/Adventures in Lestoria/assets/config/configuration.txt @@ -8,12 +8,6 @@ GAME_NAME = Adventures in Lestoria # Graphics Loading Config gfx_config = gfx/gfx.txt -Interface -{ - # The size of each side of the 9-patch menu sprite. - 9PatchSize = 24,24 -} - # Save File Server Name save_server = https://projectdivar.com:4505/AiL @@ -83,6 +77,9 @@ bgm_config = audio/bgm.txt # Path to bgm events configuration event_config = audio/events.txt +# Path to interface configuration +interface_config = interface.txt + # Path to character images character_image_location = characters/