Inputs under the same functional name now are grouped together in the input helper.

pull/35/head
sigonasr2 1 year ago
parent 2b9f770d36
commit 7434079e0d
  1. 3
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 1
      Adventures in Lestoria/AdventuresInLestoria.h
  3. 79
      Adventures in Lestoria/InputHelper.cpp
  4. 1
      Adventures in Lestoria/InputHelper.h
  5. 3
      Adventures in Lestoria/SaveFileWindow.cpp
  6. 2
      Adventures in Lestoria/TODO.txt
  7. 2
      Adventures in Lestoria/Version.h
  8. BIN
      x64/Release/Adventures in Lestoria.exe

@ -117,6 +117,7 @@ InputGroup AiL::KEY_FACEUP;
InputGroup AiL::KEY_FACERIGHT; InputGroup AiL::KEY_FACERIGHT;
InputGroup AiL::KEY_FACELEFT; InputGroup AiL::KEY_FACELEFT;
InputGroup AiL::KEY_FACEDOWN; InputGroup AiL::KEY_FACEDOWN;
InputGroup AiL::KEY_ENTER;
InputGroup AiL::KEY_SCROLLDOWN; InputGroup AiL::KEY_SCROLLDOWN;
InputGroup AiL::KEY_SCROLLUP; InputGroup AiL::KEY_SCROLLUP;
@ -2503,6 +2504,8 @@ void AiL::InitializeDefaultKeybinds(){
KEY_MENU.AddKeybind({KEY,ESCAPE}); KEY_MENU.AddKeybind({KEY,ESCAPE});
KEY_MENU.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::START)}); KEY_MENU.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::START)});
KEY_ENTER.AddKeybind({KEY,ENTER});
KEY_FASTSCROLLUP.AddKeybind({KEY,Q}); KEY_FASTSCROLLUP.AddKeybind({KEY,Q});
KEY_FASTSCROLLUP.AddKeybind({KEY,PGUP}); KEY_FASTSCROLLUP.AddKeybind({KEY,PGUP});
KEY_FASTSCROLLUP.AddKeybind({KEY,NP8}); KEY_FASTSCROLLUP.AddKeybind({KEY,NP8});

@ -105,6 +105,7 @@ public:
static InputGroup KEY_SCROLL; static InputGroup KEY_SCROLL;
static InputGroup KEY_SHOULDER; static InputGroup KEY_SHOULDER;
static InputGroup KEY_CHANGE_LOADOUT; static InputGroup KEY_CHANGE_LOADOUT;
static InputGroup KEY_ENTER;
static float SIZE_CHANGE_SPEED; static float SIZE_CHANGE_SPEED;
double levelTime; double levelTime;

@ -50,6 +50,12 @@ void InputHelper::Initialize(MenuInputGroups&inputGroups){
this->inputGroups.clear(); this->inputGroups.clear();
for(auto&data:inputGroups){ for(auto&data:inputGroups){
if(data.first.GetLabelVisible()){ //If the label is not visible, we don't care to include it in our list. if(data.first.GetLabelVisible()){ //If the label is not visible, we don't care to include it in our list.
if(std::holds_alternative<ButtonName>(data.second.first)){
const ButtonName&name=std::get<ButtonName>(data.second.first);
groupedInputs[name].push_back(data.first.GetGroup());
if(groupedInputs[name].size()>1)continue; //Skip adding to the list of input groups because this input already has been added.
}
this->inputGroups[data.first.GetGroup()]=data.second.first; this->inputGroups[data.first.GetGroup()]=data.second.first;
} }
} }
@ -69,11 +75,18 @@ void InputHelper::Draw(){
case KEY:{ case KEY:{
float buttonImgWidth=0.f; float buttonImgWidth=0.f;
float buttonDescriptionWidth=0.f; float buttonDescriptionWidth=0.f;
std::vector<std::variant<Decal*,std::string>>buttonImgs; //Store decals for buttons that actually have images, and strings for buttons that have labels. std::vector<std::vector<std::variant<Decal*,std::string>>>buttonImgs; //Store decals for buttons that actually have images, and strings for buttons that have labels. One button can have multiple icons. Store them all together.
std::vector<std::string>buttonDescriptions; std::vector<std::string>buttonDescriptions;
#pragma region Populate all buttons to display #pragma region Populate all buttons to display
for(auto&[group,display]:inputGroups){ for(auto&[group,display]:inputGroups){
auto&primaryKey=group.GetPrimaryKey(mode);
size_t groupedInputCount=1;
std::vector<InputGroup>inputGroupsToCheck;
if(std::holds_alternative<std::string>(display)&&groupedInputs.count(std::get<std::string>(display))){
inputGroupsToCheck=groupedInputs.at(std::get<std::string>(display));
}else{
inputGroupsToCheck.push_back(group);
}
std::string displayName; std::string displayName;
@ -88,19 +101,26 @@ void InputHelper::Draw(){
} }
else ERR("WARNING! display contains a variant alternative that does not exist. THIS SHOULD NOT BE HAPPENING!"); else ERR("WARNING! display contains a variant alternative that does not exist. THIS SHOULD NOT BE HAPPENING!");
if(displayName.length()>0&&primaryKey.has_value()){ buttonImgs.push_back({});
if(primaryKey.value().HasIcon()){ std::vector<std::variant<Decal*,std::string>>&iconList=buttonImgs.back();
buttonImgWidth+=primaryKey.value().GetIcon().Sprite()->width+"Interface.InputHelperSpacing"_I;
buttonImgs.push_back(primaryKey.value().GetIcon().Decal());
}else{
buttonImgWidth+=game->GetTextSizeProp(primaryKey.value().GetDisplayName()).x+"Interface.InputHelperSpacing"_I;
buttonImgs.push_back(primaryKey.value().GetDisplayName());
}
vf2d descriptionSize=game->GetTextSizeProp(displayName); for(InputGroup&group:inputGroupsToCheck){
buttonDescriptionWidth+=descriptionSize.x+"Interface.InputHelperSpacing"_I; auto&primaryKey=group.GetPrimaryKey(mode);
buttonDescriptions.push_back(displayName);
if(displayName.length()>0&&primaryKey.has_value()){
if(primaryKey.value().HasIcon()){
buttonImgWidth+=primaryKey.value().GetIcon().Sprite()->width+"Interface.InputHelperSpacing"_I;
iconList.push_back(primaryKey.value().GetIcon().Decal());
}else{
buttonImgWidth+=game->GetTextSizeProp(primaryKey.value().GetDisplayName()).x+"Interface.InputHelperSpacing"_I;
iconList.push_back(primaryKey.value().GetDisplayName());
}
}
} }
vf2d descriptionSize=game->GetTextSizeProp(displayName);
buttonDescriptionWidth+=descriptionSize.x+"Interface.InputHelperSpacing"_I;
buttonDescriptions.push_back(displayName);
} }
#pragma endregion #pragma endregion
@ -119,22 +139,23 @@ void InputHelper::Draw(){
#pragma region Draw all button inputs and descriptions #pragma region Draw all button inputs and descriptions
float xOffset="Interface.InputHelperSpacing"_I; float xOffset="Interface.InputHelperSpacing"_I;
for(size_t index=0;auto&button:buttonImgs){ for(size_t index=0;auto&buttonList:buttonImgs){
if(std::holds_alternative<Decal*>(button)){ for(std::variant<Decal*,std::string>button:buttonList){
Decal*img=std::get<Decal*>(button); if(std::holds_alternative<Decal*>(button)){
game->DrawDecal(vf2d{xOffset,float(WINDOW_SIZE.y-img->sprite->height)-4},img); Decal*img=std::get<Decal*>(button);
xOffset+=img->sprite->width+"Interface.InputHelperSpacing"_I; game->DrawDecal(vf2d{xOffset,float(WINDOW_SIZE.y-img->sprite->height)-4},img);
}else xOffset+=img->sprite->width+"Interface.InputHelperSpacing"_I;
if(std::holds_alternative<std::string>(button)){ }else
std::string label=std::get<std::string>(button); if(std::holds_alternative<std::string>(button)){
vf2d textSize=game->GetTextSizeProp(label); std::string label=std::get<std::string>(button);
game->FillRectDecal(vf2d{xOffset-2,float(WINDOW_SIZE.y-textSize.y-6)},vf2d{textSize.x+4,textSize.y},"Interface.InputButtonBackCol"_Pixel); vf2d textSize=game->GetTextSizeProp(label);
game->FillRectDecal(vf2d{xOffset-1,float(WINDOW_SIZE.y-textSize.y-6)-1.f},vf2d{textSize.x+2,textSize.y},"Interface.InputButtonBackCol"_Pixel); game->FillRectDecal(vf2d{xOffset-2,float(WINDOW_SIZE.y-textSize.y-6)},vf2d{textSize.x+4,textSize.y},"Interface.InputButtonBackCol"_Pixel);
game->FillRectDecal(vf2d{xOffset-1,float(WINDOW_SIZE.y-textSize.y-6)},vf2d{textSize.x+2,textSize.y+1.f},"Interface.InputButtonBackCol"_Pixel); game->FillRectDecal(vf2d{xOffset-1,float(WINDOW_SIZE.y-textSize.y-6)-1.f},vf2d{textSize.x+2,textSize.y},"Interface.InputButtonBackCol"_Pixel);
game->DrawStringPropDecal(vf2d{xOffset,float(WINDOW_SIZE.y-textSize.y-6)},label,"Interface.InputButtonTextCol"_Pixel); game->FillRectDecal(vf2d{xOffset-1,float(WINDOW_SIZE.y-textSize.y-6)},vf2d{textSize.x+2,textSize.y+1.f},"Interface.InputButtonBackCol"_Pixel);
xOffset+=textSize.x+"Interface.InputHelperSpacing"_I; game->DrawStringPropDecal(vf2d{xOffset,float(WINDOW_SIZE.y-textSize.y-6)},label,"Interface.InputButtonTextCol"_Pixel);
}else [[unlikely]]ERR("WARNING! Hit a state where no data is inside of the button! THIS SHOULD NOT BE HAPPENING!"); xOffset+=textSize.x+"Interface.InputHelperSpacing"_I;
}else [[unlikely]]ERR("WARNING! Hit a state where no data is inside of the button! THIS SHOULD NOT BE HAPPENING!");
}
std::string_view description=buttonDescriptions[index]; std::string_view description=buttonDescriptions[index];
vf2d descriptionTextSize=game->GetTextSizeProp(description)*vf2d{buttonDescriptionScaleX,1.f}; vf2d descriptionTextSize=game->GetTextSizeProp(description)*vf2d{buttonDescriptionScaleX,1.f};
game->DrawShadowStringPropDecal(vf2d{xOffset,float(WINDOW_SIZE.y-descriptionTextSize.y-6)},description,WHITE,BLACK,vf2d{buttonDescriptionScaleX,1.f}); game->DrawShadowStringPropDecal(vf2d{xOffset,float(WINDOW_SIZE.y-descriptionTextSize.y-6)},description,WHITE,BLACK,vf2d{buttonDescriptionScaleX,1.f});

@ -45,6 +45,7 @@ All rights reserved.
class InputHelper{ class InputHelper{
std::map<InputGroup,InputGroupActionDisplayName>inputGroups; std::map<InputGroup,InputGroupActionDisplayName>inputGroups;
std::map<ButtonName,std::vector<InputGroup>>groupedInputs;
const InputType InputMode()const; const InputType InputMode()const;

@ -63,6 +63,9 @@ void Menu::InitializeSaveFileWindow(){
{game->KEY_START,{"Confirm Character Name",[](MenuType type){ {game->KEY_START,{"Confirm Character Name",[](MenuType type){
Component<MenuComponent>(type,"Continue Button")->Click(); Component<MenuComponent>(type,"Continue Button")->Click();
}}}, }}},
{game->KEY_ENTER,{"Confirm Character Name",[](MenuType type){
Component<MenuComponent>(type,"Continue Button")->Click();
}}},
{game->KEY_SELECT,{"Cancel",[](MenuType type){ {game->KEY_SELECT,{"Cancel",[](MenuType type){
Component<MenuComponent>(type,"Back Button")->Click(); Component<MenuComponent>(type,"Back Button")->Click();
}}}, }}},

@ -9,6 +9,8 @@ January 1st
- Add screen shake and rumble as a toggle. - Add screen shake and rumble as a toggle.
- Toggle between Playstation / Xbox controller gamepad displays
- Rebind FACELEFT/FACERIGHT menu keys (as they are used constantly throughout menus and would need to be rebinded if the player wants). (Or make confirm/back not rebindable)
January 31st January 31st
============ ============

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 3 #define VERSION_MINOR 3
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 7300 #define VERSION_BUILD 7313
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

Loading…
Cancel
Save