Version number updated to 1.0.0. Handle analog input hints for steam icons. Release Build 8348.
This commit is contained in:
@@ -45,6 +45,8 @@ INCLUDE_game
|
||||
INCLUDE_GFX
|
||||
INCLUDE_WINDOW_SIZE
|
||||
|
||||
using IconScale=float;
|
||||
|
||||
InputHelper::InputHelper(){}
|
||||
|
||||
void InputHelper::Initialize(MenuInputGroups&inputGroups){
|
||||
@@ -62,13 +64,25 @@ const InputType InputHelper::InputMode()const{
|
||||
|
||||
void InputHelper::Draw(){
|
||||
InputType mode=InputMode();
|
||||
if(mode==CONTROLLER&&SteamInput())mode=STEAM;
|
||||
if(mode==MOUSE)mode=KEY; //We're going to make it so the keyboard controls always show up when navigating using a mouse.
|
||||
|
||||
auto OriginalGameIcon=[](std::optional<Input>input)->bool{
|
||||
if(input.has_value()){
|
||||
EInputActionOrigin action=Input::steamGameInputToOrigin.at(Steam::SteamInput(input.value().key)).second[0];
|
||||
EInputActionOrigin analogAction=Input::steamGameInputToAnalogOrigin.at(Steam::SteamInput(input.value().key)).second[0];
|
||||
return Input::steamIconToGameIcon.count(action)+Input::steamIconToGameIcon.count(analogAction);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
switch(mode){
|
||||
case STEAM:
|
||||
case CONTROLLER:
|
||||
case KEY:{
|
||||
float buttonImgWidth=0.f;
|
||||
float buttonDescriptionWidth=0.f;
|
||||
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::vector<std::pair<IconScale,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
|
||||
inputGroups.clear();
|
||||
@@ -116,7 +130,7 @@ void InputHelper::Draw(){
|
||||
}
|
||||
|
||||
buttonImgs.push_back({});
|
||||
std::vector<std::variant<Decal*,std::string>>&iconList=buttonImgs.back();
|
||||
std::vector<std::pair<IconScale,std::variant<Decal*,std::string>>>&iconList=buttonImgs.back();
|
||||
|
||||
for(InputGroup&group:inputGroupsToCheck){
|
||||
if(Menu::UsingMouseNavigation()){
|
||||
@@ -125,14 +139,14 @@ void InputHelper::Draw(){
|
||||
if(displayName.length()>0&&primaryKey.has_value()){
|
||||
if(primaryKey.value().HasExtendedIcons()){//This means it follows the specialized icon controller schemes, now pick based on these icons.
|
||||
buttonImgWidth+=primaryKey.value().GetIcon(GameSettings::GetIconType()).Sprite()->width+"Interface.InputHelperSpacing"_I;
|
||||
iconList.push_back(primaryKey.value().GetIcon(GameSettings::GetIconType()).Decal());
|
||||
iconList.push_back({1.f,primaryKey.value().GetIcon(GameSettings::GetIconType()).Decal()});
|
||||
}else
|
||||
if(primaryKey.value().HasIcon()){
|
||||
buttonImgWidth+=primaryKey.value().GetIcon().Sprite()->width+"Interface.InputHelperSpacing"_I;
|
||||
iconList.push_back(primaryKey.value().GetIcon().Decal());
|
||||
iconList.push_back({1.f,primaryKey.value().GetIcon().Decal()});
|
||||
}else{
|
||||
buttonImgWidth+=game->GetTextSizeProp(primaryKey.value().GetDisplayName()).x+"Interface.InputHelperSpacing"_I;
|
||||
iconList.push_back(primaryKey.value().GetDisplayName());
|
||||
iconList.push_back({1.f,primaryKey.value().GetDisplayName()});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,14 +156,18 @@ void InputHelper::Draw(){
|
||||
if(displayName.length()>0&&primaryKey.has_value()){
|
||||
if(primaryKey.value().HasExtendedIcons()){//This means it follows the specialized icon controller schemes, now pick based on these icons.
|
||||
buttonImgWidth+=primaryKey.value().GetIcon(GameSettings::GetIconType()).Sprite()->width+"Interface.InputHelperSpacing"_I;
|
||||
iconList.push_back(primaryKey.value().GetIcon(GameSettings::GetIconType()).Decal());
|
||||
iconList.push_back({1.f,primaryKey.value().GetIcon(GameSettings::GetIconType()).Decal()});
|
||||
}else
|
||||
if(primaryKey.value().HasIcon()){
|
||||
buttonImgWidth+=primaryKey.value().GetIcon().Sprite()->width+"Interface.InputHelperSpacing"_I;
|
||||
iconList.push_back(primaryKey.value().GetIcon().Decal());
|
||||
float alteredIconScale=1.f;
|
||||
|
||||
if(mode==STEAM&&!OriginalGameIcon(primaryKey))alteredIconScale/=2.85f; //They are initially 32x32.
|
||||
|
||||
buttonImgWidth+=primaryKey.value().GetIcon().Sprite()->width*alteredIconScale+"Interface.InputHelperSpacing"_I;
|
||||
iconList.push_back({alteredIconScale,primaryKey.value().GetIcon().Decal()});
|
||||
}else{
|
||||
buttonImgWidth+=game->GetTextSizeProp(primaryKey.value().GetDisplayName()).x+"Interface.InputHelperSpacing"_I;
|
||||
iconList.push_back(primaryKey.value().GetDisplayName());
|
||||
iconList.push_back({1.f,primaryKey.value().GetDisplayName()});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,11 +194,11 @@ void InputHelper::Draw(){
|
||||
#pragma region Draw all button inputs and descriptions
|
||||
float xOffset="Interface.InputHelperSpacing"_I;
|
||||
for(size_t index=0;auto&buttonList:buttonImgs){
|
||||
for(std::variant<Decal*,std::string>button:buttonList){
|
||||
for(auto&[iconScale,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;
|
||||
game->DrawDecal(vf2d{xOffset,float(WINDOW_SIZE.y-img->sprite->height*iconScale)-4},img,vf2d{1.f,1.f}*iconScale);
|
||||
xOffset+=img->sprite->width*iconScale+"Interface.InputHelperSpacing"_I;
|
||||
}else
|
||||
if(std::holds_alternative<std::string>(button)){
|
||||
std::string label=std::get<std::string>(button);
|
||||
|
||||
Reference in New Issue
Block a user