Added proper icon return based on button style game setting and proper icon translation when a current graphic of that button exists by default. Release Build 8336.
This commit is contained in:
parent
cd1e989e5e
commit
db5b071689
@ -664,6 +664,15 @@ void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*cons
|
||||
|
||||
void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedView*const,ViewPort*const>renderer,const vf2d pos,const std::string_view displayText,const uint8_t alpha,InputType type,vf2d textScale)const{
|
||||
std::optional<Input>primaryKey;
|
||||
|
||||
auto OriginalGameIcon=[](std::optional<Input>input)->bool{
|
||||
if(input.has_value()){
|
||||
EInputActionOrigin action=Input::steamGameInputToOrigin.at(Steam::SteamInput(input.value().key)).second[0];
|
||||
return Input::steamIconToGameIcon.count(action);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
switch(type){
|
||||
case CONTROLLER:{
|
||||
if(SteamInput()){
|
||||
@ -710,7 +719,9 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
|
||||
if(primaryKey.value().HasIcon()){
|
||||
float alteredIconScale=1.f;
|
||||
|
||||
if(type==STEAM)alteredIconScale/=2.85f; //They are initially 32x32.
|
||||
if(type==STEAM&&!OriginalGameIcon(primaryKey)){
|
||||
alteredIconScale/=2.85f; //They are initially 32x32.
|
||||
}
|
||||
|
||||
buttonImgSize.x+=primaryKey.value().GetIcon().Sprite()->width*alteredIconScale*textScale.x+"Interface.InputHelperSpacing"_F;
|
||||
buttonImgSize.y=std::max(buttonImgSize.y,float(primaryKey.value().GetIcon().Sprite()->height*alteredIconScale));
|
||||
@ -733,7 +744,7 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
|
||||
#define Render(rendererType) \
|
||||
float alteredIconScale=1.f; \
|
||||
\
|
||||
if(type==STEAM)alteredIconScale/=2.85f; /*They are initially 32x32.*/ \
|
||||
if(type==STEAM&&!OriginalGameIcon(primaryKey))alteredIconScale/=2.85f; /*They are initially 32x32.*/ \
|
||||
std::get<rendererType*const>(renderer)->DrawDecal(pos+offset-vf2d{0.f,2.f},img,alteredIconScale*textScale,{255,255,255,alpha});
|
||||
#pragma endregion
|
||||
if(std::holds_alternative<AiL*const>(renderer)){
|
||||
@ -802,6 +813,34 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
|
||||
DrawPrimaryInput(renderer,pos,displayText,alpha,primaryType);
|
||||
}
|
||||
|
||||
std::string Input::GetProperIconName(std::string currentIconName)const{
|
||||
switch(GameSettings::GetIconType()){
|
||||
case IconType::XB:{
|
||||
return currentIconName;
|
||||
}break;
|
||||
case IconType::PS:{
|
||||
if(currentIconName.ends_with("_xb.png")){
|
||||
return currentIconName.replace(currentIconName.rfind("_xb.png"),7,"_ps.png");
|
||||
}
|
||||
}break;
|
||||
case IconType::XB_REVERSED:{
|
||||
if(currentIconName.ends_with("_d_xb.png")){
|
||||
return currentIconName.replace(currentIconName.rfind("_d_xb.png"),9,"_r_xb.png");
|
||||
}else
|
||||
if(currentIconName.ends_with("_u_xb.png")){
|
||||
return currentIconName.replace(currentIconName.rfind("_u_xb.png"),9,"_l_xb.png");
|
||||
}else
|
||||
if(currentIconName.ends_with("_l_xb.png")){
|
||||
return currentIconName.replace(currentIconName.rfind("_l_xb.png"),9,"_u_xb.png");
|
||||
}else
|
||||
if(currentIconName.ends_with("_r_xb.png")){
|
||||
return currentIconName.replace(currentIconName.rfind("_r_xb.png"),9,"_d_xb.png");
|
||||
}
|
||||
}break;
|
||||
}
|
||||
return currentIconName;
|
||||
}
|
||||
|
||||
const bool Input::HasIcon()const{
|
||||
if(type==STEAM){
|
||||
return Input::steamGameInputToOrigin.count(Steam::SteamInput(key))&&
|
||||
@ -816,8 +855,12 @@ const bool Input::HasExtendedIcons()const{
|
||||
const Renderable&Input::GetIcon()const{
|
||||
if(type==STEAM){
|
||||
EInputActionOrigin action=Input::steamGameInputToOrigin.at(Steam::SteamInput(key)).second[0];
|
||||
if(steamIconToGameIcon.count(action)){
|
||||
return GFX.at(GetProperIconName(steamIconToGameIcon[action]));
|
||||
}else{
|
||||
return GFX.at(SteamInput()->GetGlyphPNGForActionOrigin(action,k_ESteamInputGlyphSize_Small,0));
|
||||
}
|
||||
}
|
||||
return GFX.at(GenericKey::keyLiteral.at({type,key}).iconName);
|
||||
}
|
||||
const Renderable&Input::GetIcon(IconType type)const{
|
||||
|
@ -137,6 +137,7 @@ public:
|
||||
const Renderable&GetIcon(IconType type)const;
|
||||
const int GetKeyCode()const;
|
||||
friend const bool operator==(const Input&input1,const Input&input2);
|
||||
std::string GetProperIconName(std::string currentIconName)const;
|
||||
static uint64_t ingameControlsHandle;
|
||||
};
|
||||
|
||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 5
|
||||
#define VERSION_PATCH 1
|
||||
#define VERSION_BUILD 8330
|
||||
#define VERSION_BUILD 8336
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user