Inputs under the same functional name now are grouped together in the input helper.
This commit is contained in:
parent
2b9f770d36
commit
7434079e0d
@ -117,6 +117,7 @@ InputGroup AiL::KEY_FACEUP;
|
||||
InputGroup AiL::KEY_FACERIGHT;
|
||||
InputGroup AiL::KEY_FACELEFT;
|
||||
InputGroup AiL::KEY_FACEDOWN;
|
||||
InputGroup AiL::KEY_ENTER;
|
||||
|
||||
InputGroup AiL::KEY_SCROLLDOWN;
|
||||
InputGroup AiL::KEY_SCROLLUP;
|
||||
@ -2503,6 +2504,8 @@ void AiL::InitializeDefaultKeybinds(){
|
||||
KEY_MENU.AddKeybind({KEY,ESCAPE});
|
||||
KEY_MENU.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::START)});
|
||||
|
||||
KEY_ENTER.AddKeybind({KEY,ENTER});
|
||||
|
||||
KEY_FASTSCROLLUP.AddKeybind({KEY,Q});
|
||||
KEY_FASTSCROLLUP.AddKeybind({KEY,PGUP});
|
||||
KEY_FASTSCROLLUP.AddKeybind({KEY,NP8});
|
||||
|
||||
@ -105,6 +105,7 @@ public:
|
||||
static InputGroup KEY_SCROLL;
|
||||
static InputGroup KEY_SHOULDER;
|
||||
static InputGroup KEY_CHANGE_LOADOUT;
|
||||
static InputGroup KEY_ENTER;
|
||||
|
||||
static float SIZE_CHANGE_SPEED;
|
||||
double levelTime;
|
||||
|
||||
@ -50,6 +50,12 @@ void InputHelper::Initialize(MenuInputGroups&inputGroups){
|
||||
this->inputGroups.clear();
|
||||
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(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;
|
||||
}
|
||||
}
|
||||
@ -69,11 +75,18 @@ void InputHelper::Draw(){
|
||||
case KEY:{
|
||||
float buttonImgWidth=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;
|
||||
#pragma region Populate all buttons to display
|
||||
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;
|
||||
|
||||
@ -87,20 +100,27 @@ void InputHelper::Draw(){
|
||||
displayName=std::get<std::function<std::string(MenuFuncData)>>(display)(MenuFuncData{*Menu::stack.back(),game,Menu::stack.back()->GetSelection(),parentComponent});
|
||||
}
|
||||
else ERR("WARNING! display contains a variant alternative that does not exist. THIS SHOULD NOT BE HAPPENING!");
|
||||
|
||||
buttonImgs.push_back({});
|
||||
std::vector<std::variant<Decal*,std::string>>&iconList=buttonImgs.back();
|
||||
|
||||
if(displayName.length()>0&&primaryKey.has_value()){
|
||||
if(primaryKey.value().HasIcon()){
|
||||
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());
|
||||
for(InputGroup&group:inputGroupsToCheck){
|
||||
auto&primaryKey=group.GetPrimaryKey(mode);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
vf2d descriptionSize=game->GetTextSizeProp(displayName);
|
||||
buttonDescriptionWidth+=descriptionSize.x+"Interface.InputHelperSpacing"_I;
|
||||
buttonDescriptions.push_back(displayName);
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
@ -119,27 +139,28 @@ void InputHelper::Draw(){
|
||||
|
||||
#pragma region Draw all button inputs and descriptions
|
||||
float xOffset="Interface.InputHelperSpacing"_I;
|
||||
for(size_t index=0;auto&button:buttonImgs){
|
||||
if(std::holds_alternative<Decal*>(button)){
|
||||
Decal*img=std::get<Decal*>(button);
|
||||
game->DrawDecal(vf2d{xOffset,float(WINDOW_SIZE.y-img->sprite->height)-4},img);
|
||||
xOffset+=img->sprite->width+"Interface.InputHelperSpacing"_I;
|
||||
}else
|
||||
if(std::holds_alternative<std::string>(button)){
|
||||
std::string label=std::get<std::string>(button);
|
||||
vf2d textSize=game->GetTextSizeProp(label);
|
||||
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)-1.f},vf2d{textSize.x+2,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->DrawStringPropDecal(vf2d{xOffset,float(WINDOW_SIZE.y-textSize.y-6)},label,"Interface.InputButtonTextCol"_Pixel);
|
||||
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!");
|
||||
|
||||
for(size_t index=0;auto&buttonList:buttonImgs){
|
||||
for(std::variant<Decal*,std::string>button:buttonList){
|
||||
if(std::holds_alternative<Decal*>(button)){
|
||||
Decal*img=std::get<Decal*>(button);
|
||||
game->DrawDecal(vf2d{xOffset,float(WINDOW_SIZE.y-img->sprite->height)-4},img);
|
||||
xOffset+=img->sprite->width+"Interface.InputHelperSpacing"_I;
|
||||
}else
|
||||
if(std::holds_alternative<std::string>(button)){
|
||||
std::string label=std::get<std::string>(button);
|
||||
vf2d textSize=game->GetTextSizeProp(label);
|
||||
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)-1.f},vf2d{textSize.x+2,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->DrawStringPropDecal(vf2d{xOffset,float(WINDOW_SIZE.y-textSize.y-6)},label,"Interface.InputButtonTextCol"_Pixel);
|
||||
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];
|
||||
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});
|
||||
xOffset+=descriptionTextSize.x+"Interface.InputHelperSpacing"_I*buttonDescriptionScaleX;
|
||||
|
||||
|
||||
index++;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
@ -45,6 +45,7 @@ All rights reserved.
|
||||
|
||||
class InputHelper{
|
||||
std::map<InputGroup,InputGroupActionDisplayName>inputGroups;
|
||||
std::map<ButtonName,std::vector<InputGroup>>groupedInputs;
|
||||
|
||||
const InputType InputMode()const;
|
||||
|
||||
|
||||
@ -63,6 +63,9 @@ void Menu::InitializeSaveFileWindow(){
|
||||
{game->KEY_START,{"Confirm Character Name",[](MenuType type){
|
||||
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){
|
||||
Component<MenuComponent>(type,"Back Button")->Click();
|
||||
}}},
|
||||
|
||||
@ -9,6 +9,8 @@ January 1st
|
||||
|
||||
- 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
|
||||
============
|
||||
|
||||
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 7300
|
||||
#define VERSION_BUILD 7313
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user