Add in analog stick control handling. Add interface configuration file.

pull/35/head
Nic0Nic0Nii 1 year ago
parent 7cf44b2462
commit df08aa9936
  1. 8
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 2
      Adventures in Lestoria/AdventuresInLestoria.h
  3. 21
      Adventures in Lestoria/Key.cpp
  4. 4
      Adventures in Lestoria/Key.h
  5. 4
      Adventures in Lestoria/LoadGameWindow.cpp
  6. 8
      Adventures in Lestoria/assets/config/Interface.txt
  7. 9
      Adventures in Lestoria/assets/config/configuration.txt

@ -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<int>(GPButtons::START)});
KEY_SELECT.AddKeybind({KEY,ESCAPE});
KEY_SELECT.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::SELECT)});
KEY_SCROLL.AddKeybind({ANALOG,static_cast<int>(GPAxes::LY)});
KEY_SCROLL.AddKeybind({ANALOG,static_cast<int>(GPAxes::RY)});
}
void AiL::SetBossNameDisplay(std::string name,float time){

@ -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;

@ -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<GPAxes>(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 "<<type);
}
}
return 0.f;
}
std::string Input::GetDisplayName(){
return GenericKey::keyLiteral.at({type,key});
}

@ -44,7 +44,8 @@ All rights reserved.
enum InputType{
KEY,
MOUSE,
CONTROLLER
CONTROLLER,
ANALOG,
};
//A generic class that represents any type of input.
@ -59,6 +60,7 @@ public:
bool Pressed();
bool Held();
bool Released();
float Analog();
std::string GetDisplayName();
bool operator<(const Input&rhs)const{
return type<rhs.type||(type==rhs.type&&key<rhs.key);

@ -59,6 +59,10 @@ void Menu::InitializeLoadGameWindow(){
{game->KEY_BACK,{"Back to Title Screen",[](MenuType type){
Component<MenuComponent>(type,"Go Back Button")->Click();
}}},
{game->KEY_SCROLL,{"Scroll Up/Down",[](MenuType type){
auto&scrollWindow=Component<ScrollableWindowComponent>(type,"Game Files List");
scrollWindow->SetScrollAmount(scrollWindow->GetScrollAmount()+game->KEY_SCROLL.Analog()*game->GetElapsedTime()*"Interface.AnalogScrollSpeed"_F);
}}},
}
,{ //Button Navigation Rules
{"Game Files List",{

@ -0,0 +1,8 @@
Interface
{
# In pixels/sec
AnalogScrollSpeed = 120
# The size of each side of the 9-patch menu sprite.
9PatchSize = 24,24
}

@ -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/

Loading…
Cancel
Save