Add Steam input binding groups to tutorial tasks. Release Build 8357.

mac-build
sigonasr2 8 months ago
parent 41228265b2
commit d442095fde
  1. 5
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 1
      Adventures in Lestoria/AdventuresInLestoria.h
  3. 28
      Adventures in Lestoria/Key.cpp
  4. 47
      Adventures in Lestoria/Player.cpp
  5. 3
      Adventures in Lestoria/Player.h
  6. 32
      Adventures in Lestoria/Tutorial.h
  7. 2
      Adventures in Lestoria/Version.h
  8. 5
      Adventures in Lestoria/olcUTIL_Animate2D.h
  9. BIN
      x64/Release/Adventures in Lestoria.exe

@ -134,6 +134,7 @@ InputGroup AiL::KEY_SCROLLLEFT;
InputGroup AiL::KEY_SCROLLRIGHT; InputGroup AiL::KEY_SCROLLRIGHT;
InputGroup AiL::KEY_SCROLLHORZ; InputGroup AiL::KEY_SCROLLHORZ;
InputGroup AiL::KEY_SCROLLHORZ_L; InputGroup AiL::KEY_SCROLLHORZ_L;
InputGroup AiL::KEY_SCROLLHORZ_R;
InputGroup AiL::KEY_SCROLLVERT; InputGroup AiL::KEY_SCROLLVERT;
InputGroup AiL::KEY_SCROLLVERT_R; InputGroup AiL::KEY_SCROLLVERT_R;
InputGroup AiL::KEY_SCROLLVERT_L; InputGroup AiL::KEY_SCROLLVERT_L;
@ -2980,9 +2981,11 @@ void AiL::InitializeDefaultKeybinds(){
KEY_SCROLLVERT_L.AddKeybind({STEAM,Steam::SCROLL}); KEY_SCROLLVERT_L.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLLVERT_R.AddKeybind({ANALOG,static_cast<int>(GPAxes::RY)}); KEY_SCROLLVERT_R.AddKeybind({ANALOG,static_cast<int>(GPAxes::RY)});
KEY_SCROLLVERT_R.AddKeybind({STEAM,Steam::SCROLL}); KEY_SCROLLVERT_R.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast<int>(GPAxes::LX)});
KEY_SCROLLHORZ_L.AddKeybind({ANALOG,static_cast<int>(GPAxes::LX)}); KEY_SCROLLHORZ_L.AddKeybind({ANALOG,static_cast<int>(GPAxes::LX)});
KEY_SCROLLHORZ_L.AddKeybind({STEAM,Steam::SCROLL}); KEY_SCROLLHORZ_L.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLLHORZ_R.AddKeybind({ANALOG,static_cast<int>(GPAxes::RX)});
KEY_SCROLLHORZ_R.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast<int>(GPAxes::LX)});
KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast<int>(GPAxes::RX)}); KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast<int>(GPAxes::RX)});
KEY_SCROLLHORZ.AddKeybind({STEAM,Steam::SCROLL}); KEY_SCROLLHORZ.AddKeybind({STEAM,Steam::SCROLL});
KEY_SCROLL.AddKeybind({KEY,ARROWS}); KEY_SCROLL.AddKeybind({KEY,ARROWS});

@ -105,6 +105,7 @@ public:
static InputGroup KEY_SCROLLRIGHT; static InputGroup KEY_SCROLLRIGHT;
static InputGroup KEY_SCROLLHORZ; static InputGroup KEY_SCROLLHORZ;
static InputGroup KEY_SCROLLHORZ_L; static InputGroup KEY_SCROLLHORZ_L;
static InputGroup KEY_SCROLLHORZ_R;
static InputGroup KEY_SCROLLVERT; static InputGroup KEY_SCROLLVERT;
static InputGroup KEY_SCROLLVERT_R; static InputGroup KEY_SCROLLVERT_R;
static InputGroup KEY_SCROLLVERT_L; static InputGroup KEY_SCROLLVERT_L;

@ -1056,20 +1056,26 @@ const bool Input::UsingGamepad(){
const bool Input::AxesActive(){ const bool Input::AxesActive(){
float xAxis=0.f,yAxis=0.f; float xAxis=0.f,yAxis=0.f;
for(GamePad*gamepad:GamePad::getGamepads()){ if(SteamInput()){
if(gamepad->stillConnected){ if(fabs(game->KEY_SCROLLHORZ_R.Analog())>0.f){
if(fabs(gamepad->getAxis(GPAxes::RX))>0.f){ return true;
xAxis=gamepad->getAxis(GPAxes::RX); }
} if(fabs(game->KEY_SCROLLVERT_R.Analog())>0.f){
return true;
if(fabs(gamepad->getAxis(GPAxes::RY))>0.f){ }
yAxis=gamepad->getAxis(GPAxes::RY); }else{
for(GamePad*gamepad:GamePad::getGamepads()){
if(gamepad->stillConnected){
if(fabs(gamepad->getAxis(GPAxes::RX))>0.f){
return true;
}
if(fabs(gamepad->getAxis(GPAxes::RY))>0.f){
return true;
}
} }
if(xAxis!=0.f||yAxis!=0.f)break; //Found a controller, so we're good to break.
} }
} }
return xAxis!=0.f||yAxis!=0.f; return false;
} }
void Input::StartVibration(const bool override){ void Input::StartVibration(const bool override){

@ -773,9 +773,9 @@ void Player::AddAnimation(std::string state){
animation.AddState(state,ANIMATION_DATA.at(state)); animation.AddState(state,ANIMATION_DATA.at(state));
} }
void Player::UpdateAnimation(std::string animState,int specificClass){ void Player::UpdateAnimation(std::string animState,int specificClass,const bool force){
if(specificClass==ANY||specificClass&GetClass()){ if(specificClass==ANY||specificClass&GetClass()){
animation.ChangeState(internal_animState,animState); animation.ChangeState(internal_animState,animState,force);
} }
} }
@ -974,31 +974,31 @@ void Player::SetAnimationBasedOnTargetingDirection(float targetDirection){
case Class::WARRIOR: case Class::WARRIOR:
case Class::THIEF:{ case Class::THIEF:{
if(FacingNorth()){ if(FacingNorth()){
UpdateAnimation("WARRIOR_SWINGSWORD_N"); UpdateAnimation("WARRIOR_SWINGSWORD_N",true);
}else }else
if(FacingSouth()){ if(FacingSouth()){
UpdateAnimation("WARRIOR_SWINGSWORD_S"); UpdateAnimation("WARRIOR_SWINGSWORD_S",true);
}else }else
if(FacingWest()){ if(FacingWest()){
UpdateAnimation("WARRIOR_SWINGSWORD_W"); UpdateAnimation("WARRIOR_SWINGSWORD_W",true);
}else }else
if(FacingEast()){ if(FacingEast()){
UpdateAnimation("WARRIOR_SWINGSWORD_E"); UpdateAnimation("WARRIOR_SWINGSWORD_E",true);
} }
}break; }break;
case Class::RANGER: case Class::RANGER:
case Class::TRAPPER:{ case Class::TRAPPER:{
if(FacingNorth()){ if(FacingNorth()){
UpdateAnimation("RANGER_SHOOT_N"); UpdateAnimation("RANGER_SHOOT_N",true);
}else }else
if(FacingSouth()){ if(FacingSouth()){
UpdateAnimation("RANGER_SHOOT_S"); UpdateAnimation("RANGER_SHOOT_S",true);
}else }else
if(FacingWest()){ if(FacingWest()){
UpdateAnimation("RANGER_SHOOT_W"); UpdateAnimation("RANGER_SHOOT_W",true);
}else }else
if(FacingEast()){ if(FacingEast()){
UpdateAnimation("RANGER_SHOOT_E"); UpdateAnimation("RANGER_SHOOT_E",true);
} }
}break; }break;
} }
@ -1390,17 +1390,26 @@ const vf2d Player::GetAimingLocation(bool useWalkDir,bool invert){
} }
#pragma region Manual Aiming #pragma region Manual Aiming
for(GamePad*gamepad:GamePad::getGamepads()){ if(SteamInput()){
if(gamepad->stillConnected){ if(fabs(game->KEY_SCROLLHORZ_R.Analog())>0.f){
if(fabs(gamepad->getAxis(GPAxes::RX))>0.f){ xAxis=game->KEY_SCROLLHORZ_R.Analog();
xAxis=gamepad->getAxis(GPAxes::RX); }
} if(fabs(game->KEY_SCROLLVERT_R.Analog())>0.f){
yAxis=game->KEY_SCROLLVERT_R.Analog();
}
}else{
for(GamePad*gamepad:GamePad::getGamepads()){
if(gamepad->stillConnected){
if(fabs(gamepad->getAxis(GPAxes::RX))>0.f){
xAxis=gamepad->getAxis(GPAxes::RX);
}
if(fabs(gamepad->getAxis(GPAxes::RY))>0.f){ if(fabs(gamepad->getAxis(GPAxes::RY))>0.f){
yAxis=gamepad->getAxis(GPAxes::RY); yAxis=gamepad->getAxis(GPAxes::RY);
} }
if(xAxis!=0.f||yAxis!=0.f)break; //Found a controller, so we're good to break. if(xAxis!=0.f||yAxis!=0.f)break; //Found a controller, so we're good to break.
}
} }
} }
#pragma endregion #pragma endregion

@ -177,7 +177,8 @@ public:
//Return false if healing was not possible. //Return false if healing was not possible.
bool Heal(int damage,bool suppressDamageNumber=false); bool Heal(int damage,bool suppressDamageNumber=false);
//specificClass is a bitwise-combination of classes from the Class enum. It makes sure certain animations only play if you are a certain class. //specificClass is a bitwise-combination of classes from the Class enum. It makes sure certain animations only play if you are a certain class.
void UpdateAnimation(std::string animState,int specificClass=ANY); //Set force to true to force the animation to restart evne if the animation were already playing.
void UpdateAnimation(std::string animState,int specificClass=ANY,const bool force=false);
Animate2D::Frame GetFrame(); Animate2D::Frame GetFrame();
Key GetLastReleasedMovementKey(); Key GetLastReleasedMovementKey();
float GetSwordSwingTimer(); float GetSwordSwingTimer();

@ -170,6 +170,7 @@ private:
attackGroup.ClearAllKeybinds(); attackGroup.ClearAllKeybinds();
ADDKEYBIND(attackGroup,game->KEY_ATTACK,CONTROLLER); ADDKEYBIND(attackGroup,game->KEY_ATTACK,CONTROLLER);
ADDKEYBIND(attackGroup,game->KEY_ATTACK,KEY); ADDKEYBIND(attackGroup,game->KEY_ATTACK,KEY);
ADDKEYBIND(attackGroup,game->KEY_ATTACK,STEAM);
} }
virtual inline bool CompleteCondition()override final{ virtual inline bool CompleteCondition()override final{
return I(A::ATTACK_COUNT)>=10; return I(A::ATTACK_COUNT)>=10;
@ -177,7 +178,11 @@ private:
virtual inline void OnComplete()override final{} virtual inline void OnComplete()override final{}
virtual inline void Draw()const override final{ virtual inline void Draw()const override final{
if(Input::UsingGamepad()){ if(Input::UsingGamepad()){
attackGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Attack",180,InputType::CONTROLLER); if(SteamInput()){
attackGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Attack",180,InputType::STEAM);
}else{
attackGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Attack",180,InputType::CONTROLLER);
}
}else{ }else{
attackGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Attack",180,InputType::KEY); attackGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Attack",180,InputType::KEY);
} }
@ -193,10 +198,13 @@ private:
abilityGroup.ClearAllKeybinds(); abilityGroup.ClearAllKeybinds();
ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY1,CONTROLLER); ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY1,CONTROLLER);
ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY1,KEY); ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY1,KEY);
ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY1,STEAM);
ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY2,CONTROLLER); ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY2,CONTROLLER);
ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY2,KEY); ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY2,KEY);
ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY2,STEAM);
ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY3,CONTROLLER); ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY3,CONTROLLER);
ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY3,KEY); ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY3,KEY);
ADDKEYBIND(abilityGroup,game->GetPlayer()->KEY_ABILITY3,STEAM);
} }
virtual inline bool CompleteCondition()override final{ virtual inline bool CompleteCondition()override final{
return I(A::ABILITY_COUNT)>=5; return I(A::ABILITY_COUNT)>=5;
@ -204,7 +212,11 @@ private:
virtual inline void OnComplete()override final{} virtual inline void OnComplete()override final{}
virtual inline void Draw()const override final{ virtual inline void Draw()const override final{
if(Input::UsingGamepad()){ if(Input::UsingGamepad()){
abilityGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Abilities",180,InputType::CONTROLLER); if(SteamInput()){
abilityGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Abilities",180,InputType::STEAM);
}else{
abilityGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Abilities",180,InputType::CONTROLLER);
}
}else{ }else{
abilityGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Abilities",180,InputType::KEY); abilityGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Abilities",180,InputType::KEY);
} }
@ -220,6 +232,7 @@ private:
defensiveGroup.ClearAllKeybinds(); defensiveGroup.ClearAllKeybinds();
ADDKEYBIND(defensiveGroup,game->GetPlayer()->KEY_DEFENSIVE,CONTROLLER); ADDKEYBIND(defensiveGroup,game->GetPlayer()->KEY_DEFENSIVE,CONTROLLER);
ADDKEYBIND(defensiveGroup,game->GetPlayer()->KEY_DEFENSIVE,KEY); ADDKEYBIND(defensiveGroup,game->GetPlayer()->KEY_DEFENSIVE,KEY);
ADDKEYBIND(defensiveGroup,game->GetPlayer()->KEY_DEFENSIVE,STEAM);
} }
virtual inline bool CompleteCondition()override final{ virtual inline bool CompleteCondition()override final{
return I(A::DEFENSIVE_COUNT)>=2; return I(A::DEFENSIVE_COUNT)>=2;
@ -227,7 +240,11 @@ private:
virtual inline void OnComplete()override final{} virtual inline void OnComplete()override final{}
virtual inline void Draw()const override final{ virtual inline void Draw()const override final{
if(Input::UsingGamepad()){ if(Input::UsingGamepad()){
defensiveGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Defensive Ability",180,InputType::CONTROLLER); if(SteamInput()){
defensiveGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Defensive Ability",180,InputType::STEAM);
}else{
defensiveGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Defensive Ability",180,InputType::CONTROLLER);
}
}else{ }else{
defensiveGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Defensive Ability",180,InputType::KEY); defensiveGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Defensive Ability",180,InputType::KEY);
} }
@ -244,14 +261,17 @@ private:
if(!ISBLANK(game->GetLoadoutItem(0))){ if(!ISBLANK(game->GetLoadoutItem(0))){
ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM1,CONTROLLER); ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM1,CONTROLLER);
ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM1,KEY); ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM1,KEY);
ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM1,STEAM);
} }
if(!ISBLANK(game->GetLoadoutItem(1))){ if(!ISBLANK(game->GetLoadoutItem(1))){
ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM2,CONTROLLER); ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM2,CONTROLLER);
ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM2,KEY); ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM2,KEY);
ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM2,STEAM);
} }
if(!ISBLANK(game->GetLoadoutItem(2))){ if(!ISBLANK(game->GetLoadoutItem(2))){
ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM3,CONTROLLER); ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM3,CONTROLLER);
ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM3,KEY); ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM3,KEY);
ADDKEYBIND(itemsGroup,game->GetPlayer()->KEY_ITEM3,STEAM);
} }
} }
virtual inline bool CompleteCondition()override final{ virtual inline bool CompleteCondition()override final{
@ -260,7 +280,11 @@ private:
virtual inline void OnComplete()override final{} virtual inline void OnComplete()override final{}
virtual inline void Draw()const override final{ virtual inline void Draw()const override final{
if(Input::UsingGamepad()){ if(Input::UsingGamepad()){
itemsGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Consumables",180,InputType::CONTROLLER); if(SteamInput()){
itemsGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Consumables",180,InputType::STEAM);
}else{
itemsGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Consumables",180,InputType::CONTROLLER);
}
}else{ }else{
itemsGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Consumables",180,InputType::KEY); itemsGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Consumables",180,InputType::KEY);
} }

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 0 #define VERSION_MINOR 0
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 8351 #define VERSION_BUILD 8357
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -172,10 +172,11 @@ namespace olc::utils::Animate2D
Animation() = default; Animation() = default;
// Change an animation state token to a new state // Change an animation state token to a new state
inline bool ChangeState(AnimationState& state, const StatesEnum& sStateName) const //If force is set, will reset the animation even if it's the same animation.
inline bool ChangeState(AnimationState& state, const StatesEnum& sStateName, bool force=false) const
{ {
size_t idx = m_mapStateIndices.at(sStateName); size_t idx = m_mapStateIndices.at(sStateName);
if (state.nIndex != idx) if (state.nIndex != idx )
{ {
state.fTime = 0.0f; state.fTime = 0.0f;
state.nIndex = idx; state.nIndex = idx;

Loading…
Cancel
Save