Added small background to input display. Added safeguard to prevent mouse inputs from occurring in keyboard navigation rules.
This commit is contained in:
parent
4eec0ce337
commit
a206cb10eb
Adventures in Lestoria
@ -75,6 +75,7 @@ void InputHelper::Draw(){
|
|||||||
buttonImgWidth+=primaryKey.value().GetIcon().Sprite()->width+"Interface.InputHelperSpacing"_I;
|
buttonImgWidth+=primaryKey.value().GetIcon().Sprite()->width+"Interface.InputHelperSpacing"_I;
|
||||||
buttonImgs.push_back(primaryKey.value().GetIcon().Decal());
|
buttonImgs.push_back(primaryKey.value().GetIcon().Decal());
|
||||||
}else{
|
}else{
|
||||||
|
buttonImgWidth+=game->GetTextSizeProp(primaryKey.value().GetDisplayName()).x+"Interface.InputHelperSpacing"_I;
|
||||||
buttonImgs.push_back(primaryKey.value().GetDisplayName());
|
buttonImgs.push_back(primaryKey.value().GetDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,32 +88,39 @@ void InputHelper::Draw(){
|
|||||||
|
|
||||||
float buttonDescriptionScaleX=1.0f;
|
float buttonDescriptionScaleX=1.0f;
|
||||||
|
|
||||||
if(buttonImgWidth+buttonDescriptionWidth>WINDOW_SIZE.x){
|
if(buttonImgWidth+buttonDescriptionWidth>WINDOW_SIZE.x-"Interface.InputHelperSpacing"_I){
|
||||||
buttonDescriptionScaleX=(WINDOW_SIZE.x-buttonImgWidth)/(buttonDescriptionWidth+buttonImgWidth);
|
buttonDescriptionScaleX=(WINDOW_SIZE.x-buttonImgWidth-"Interface.InputHelperSpacing"_I)/(buttonDescriptionWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma region Underlying box
|
||||||
|
if(buttonDescriptions.size()>0){
|
||||||
|
game->GradientFillRectDecal(vf2d{0.f,WINDOW_SIZE.y-16.f},vf2d{float(WINDOW_SIZE.x),16.f},
|
||||||
|
{0,0,0,64},{0,0,0,255},{0,0,0,255},{0,0,0,64});
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
#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&button:buttonImgs){
|
||||||
if(std::holds_alternative<Decal*>(button)){
|
if(std::holds_alternative<Decal*>(button)){
|
||||||
Decal*img=std::get<Decal*>(button);
|
Decal*img=std::get<Decal*>(button);
|
||||||
game->DrawDecal(vf2d{xOffset,float(WINDOW_SIZE.y-img->sprite->height)-8},img);
|
game->DrawDecal(vf2d{xOffset,float(WINDOW_SIZE.y-img->sprite->height)-4},img);
|
||||||
xOffset+=img->sprite->width+"Interface.InputHelperSpacing"_I;
|
xOffset+=img->sprite->width+"Interface.InputHelperSpacing"_I;
|
||||||
}else
|
}else
|
||||||
if(std::holds_alternative<std::string>(button)){
|
if(std::holds_alternative<std::string>(button)){
|
||||||
std::string label=std::get<std::string>(button);
|
std::string label=std::get<std::string>(button);
|
||||||
vf2d textSize=game->GetTextSizeProp(label);
|
vf2d textSize=game->GetTextSizeProp(label);
|
||||||
game->FillRectDecal(vf2d{xOffset-2,float(WINDOW_SIZE.y-textSize.y-10)},vf2d{textSize.x+4,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-10)-1.f},vf2d{textSize.x+2,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-10)},vf2d{textSize.x+2,textSize.y+1.f},"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-10)},label,"Interface.InputButtonTextCol"_Pixel);
|
game->DrawStringPropDecal(vf2d{xOffset,float(WINDOW_SIZE.y-textSize.y-6)},label,"Interface.InputButtonTextCol"_Pixel);
|
||||||
xOffset+=textSize.x+"Interface.InputHelperSpacing"_I;
|
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!");
|
}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-10)},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});
|
||||||
xOffset+=descriptionTextSize.x+"Interface.InputHelperSpacing"_I;
|
xOffset+=descriptionTextSize.x+"Interface.InputHelperSpacing"_I*buttonDescriptionScaleX;
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
@ -300,32 +300,33 @@ void Menu::OpenMenu(MenuType menu,bool cover){
|
|||||||
void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||||
std::weak_ptr<MenuComponent>prevSelection=selection;
|
std::weak_ptr<MenuComponent>prevSelection=selection;
|
||||||
|
|
||||||
for(auto&[input,data]:inputGroups){
|
if(!Menu::UsingMouseNavigation()){
|
||||||
bool activated=false;
|
for(auto&[input,data]:inputGroups){
|
||||||
switch(input.GetEngageType()){
|
bool activated=false;
|
||||||
case Released:{
|
switch(input.GetEngageType()){
|
||||||
activated=input.GetGroup().Released();
|
case Released:{
|
||||||
}break;
|
activated=input.GetGroup().Released();
|
||||||
case Pressed:{
|
}break;
|
||||||
activated=input.GetGroup().Pressed();
|
case Pressed:{
|
||||||
}break;
|
activated=input.GetGroup().Pressed();
|
||||||
case Held:{
|
}break;
|
||||||
activated=input.GetGroup().Held();
|
case Held:{
|
||||||
}break;
|
activated=input.GetGroup().Held();
|
||||||
case Analog:{
|
}break;
|
||||||
activated=input.GetGroup().Analog()!=0.f;
|
case Analog:{
|
||||||
}break;
|
activated=input.GetGroup().Analog()!=0.f;
|
||||||
[[unlikely]]default:ERR(std::format("WARNING! Unhandled input engage type {}! THIS SHOULD NOT BE HAPPENING!",int(input.GetEngageType())));
|
}break;
|
||||||
}
|
[[unlikely]]default:ERR(std::format("WARNING! Unhandled input engage type {}! THIS SHOULD NOT BE HAPPENING!",int(input.GetEngageType())));
|
||||||
|
}
|
||||||
|
|
||||||
if(activated){
|
if(activated){
|
||||||
SetMouseNavigation(false);
|
auto&action=data.second;
|
||||||
auto&action=data.second;
|
if(std::holds_alternative<ButtonName>(action))Component<MenuComponent>(type,std::get<ButtonName>(action))->Click();
|
||||||
if(std::holds_alternative<ButtonName>(action))Component<MenuComponent>(type,std::get<ButtonName>(action))->Click();
|
else
|
||||||
else
|
if(std::holds_alternative<std::function<void(MenuType)>>(action))std::get<std::function<void(MenuType)>>(action)(type);
|
||||||
if(std::holds_alternative<std::function<void(MenuType)>>(action))std::get<std::function<void(MenuType)>>(action)(type);
|
else{
|
||||||
else{
|
ERR("WARNING! Navigation data has an unrecognized type or is empty! This should not be happening!")
|
||||||
ERR("WARNING! Navigation data has an unrecognized type or is empty! This should not be happening!")
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -384,7 +385,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
|||||||
|
|
||||||
if(game->KEY_UP.Released()||game->KEY_RIGHT.Released()||game->KEY_LEFT.Released()||game->KEY_DOWN.Released()||
|
if(game->KEY_UP.Released()||game->KEY_RIGHT.Released()||game->KEY_LEFT.Released()||game->KEY_DOWN.Released()||
|
||||||
game->KEY_BACK.Released()||game->KEY_CONFIRM.Released()||game->KEY_START.Released()||game->KEY_SELECT.Released()||
|
game->KEY_BACK.Released()||game->KEY_CONFIRM.Released()||game->KEY_START.Released()||game->KEY_SELECT.Released()||
|
||||||
game->KEY_SCROLLDOWN.Released()||game->KEY_SCROLLUP.Released()){
|
game->KEY_SCROLLDOWN.Released()||game->KEY_SCROLLUP.Released()||game->KEY_SCROLL.Analog()!=0.f){
|
||||||
SetMouseNavigation(game->GetMouse(Mouse::LEFT).bReleased||game->GetMouse(Mouse::RIGHT).bReleased||game->GetMouse(Mouse::MIDDLE).bReleased); //If a click occurs we use mouse controls.
|
SetMouseNavigation(game->GetMouse(Mouse::LEFT).bReleased||game->GetMouse(Mouse::RIGHT).bReleased||game->GetMouse(Mouse::MIDDLE).bReleased); //If a click occurs we use mouse controls.
|
||||||
buttonHoldTime=0;
|
buttonHoldTime=0;
|
||||||
}
|
}
|
||||||
|
@ -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 6177
|
#define VERSION_BUILD 6190
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user