Add in analog stick control handling. Add interface configuration file.
This commit is contained in:
parent
7cf44b2462
commit
df08aa9936
@ -104,6 +104,8 @@ InputGroup AiL::KEY_BACK;
|
|||||||
InputGroup AiL::KEY_START;
|
InputGroup AiL::KEY_START;
|
||||||
InputGroup AiL::KEY_SELECT;
|
InputGroup AiL::KEY_SELECT;
|
||||||
|
|
||||||
|
InputGroup AiL::KEY_SCROLL;
|
||||||
|
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
::discord::Core*Discord{};
|
::discord::Core*Discord{};
|
||||||
#endif
|
#endif
|
||||||
@ -172,6 +174,9 @@ AiL::AiL()
|
|||||||
std::string AUDIO_CONFIG = CONFIG_PATH + "audio_config"_S;
|
std::string AUDIO_CONFIG = CONFIG_PATH + "audio_config"_S;
|
||||||
utils::datafile::Read(DATA,AUDIO_CONFIG);
|
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;
|
std::string ENVIRONMENTAL_AUDIO_CONFIG = CONFIG_PATH + "environmental_audio_config"_S;
|
||||||
utils::datafile::Read(DATA,ENVIRONMENTAL_AUDIO_CONFIG);
|
utils::datafile::Read(DATA,ENVIRONMENTAL_AUDIO_CONFIG);
|
||||||
|
|
||||||
@ -2402,6 +2407,9 @@ void AiL::InitializeDefaultKeybinds(){
|
|||||||
KEY_START.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::START)});
|
KEY_START.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::START)});
|
||||||
KEY_SELECT.AddKeybind({KEY,ESCAPE});
|
KEY_SELECT.AddKeybind({KEY,ESCAPE});
|
||||||
KEY_SELECT.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::SELECT)});
|
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){
|
void AiL::SetBossNameDisplay(std::string name,float time){
|
||||||
|
@ -87,6 +87,8 @@ public:
|
|||||||
static InputGroup KEY_START;
|
static InputGroup KEY_START;
|
||||||
static InputGroup KEY_SELECT;
|
static InputGroup KEY_SELECT;
|
||||||
|
|
||||||
|
static InputGroup KEY_SCROLL;
|
||||||
|
|
||||||
static float SIZE_CHANGE_SPEED;
|
static float SIZE_CHANGE_SPEED;
|
||||||
double levelTime;
|
double levelTime;
|
||||||
Camera2D camera;
|
Camera2D camera;
|
||||||
|
@ -125,6 +125,27 @@ bool Input::Released(){
|
|||||||
return false;
|
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(){
|
std::string Input::GetDisplayName(){
|
||||||
return GenericKey::keyLiteral.at({type,key});
|
return GenericKey::keyLiteral.at({type,key});
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,8 @@ All rights reserved.
|
|||||||
enum InputType{
|
enum InputType{
|
||||||
KEY,
|
KEY,
|
||||||
MOUSE,
|
MOUSE,
|
||||||
CONTROLLER
|
CONTROLLER,
|
||||||
|
ANALOG,
|
||||||
};
|
};
|
||||||
|
|
||||||
//A generic class that represents any type of input.
|
//A generic class that represents any type of input.
|
||||||
@ -59,6 +60,7 @@ public:
|
|||||||
bool Pressed();
|
bool Pressed();
|
||||||
bool Held();
|
bool Held();
|
||||||
bool Released();
|
bool Released();
|
||||||
|
float Analog();
|
||||||
std::string GetDisplayName();
|
std::string GetDisplayName();
|
||||||
bool operator<(const Input&rhs)const{
|
bool operator<(const Input&rhs)const{
|
||||||
return type<rhs.type||(type==rhs.type&&key<rhs.key);
|
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){
|
{game->KEY_BACK,{"Back to Title Screen",[](MenuType type){
|
||||||
Component<MenuComponent>(type,"Go Back Button")->Click();
|
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
|
,{ //Button Navigation Rules
|
||||||
{"Game Files List",{
|
{"Game Files List",{
|
||||||
|
8
Adventures in Lestoria/assets/config/Interface.txt
Normal file
8
Adventures in Lestoria/assets/config/Interface.txt
Normal file
@ -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
|
# Graphics Loading Config
|
||||||
gfx_config = gfx/gfx.txt
|
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 File Server Name
|
||||||
save_server = https://projectdivar.com:4505/AiL
|
save_server = https://projectdivar.com:4505/AiL
|
||||||
|
|
||||||
@ -83,6 +77,9 @@ bgm_config = audio/bgm.txt
|
|||||||
# Path to bgm events configuration
|
# Path to bgm events configuration
|
||||||
event_config = audio/events.txt
|
event_config = audio/events.txt
|
||||||
|
|
||||||
|
# Path to interface configuration
|
||||||
|
interface_config = interface.txt
|
||||||
|
|
||||||
# Path to character images
|
# Path to character images
|
||||||
character_image_location = characters/
|
character_image_location = characters/
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user