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.

mac-build
sigonasr2 8 months ago
parent b9c89e5715
commit 3e35645b09
  1. 47
      Adventures in Lestoria/Key.cpp
  2. 1
      Adventures in Lestoria/Key.h
  3. 2
      Adventures in Lestoria/Version.h
  4. BIN
      x64/Release/Adventures in Lestoria.exe

@ -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{ 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; 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){ switch(type){
case CONTROLLER:{ case CONTROLLER:{
if(SteamInput()){ if(SteamInput()){
@ -710,7 +719,9 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
if(primaryKey.value().HasIcon()){ if(primaryKey.value().HasIcon()){
float alteredIconScale=1.f; 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.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)); 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) \ #define Render(rendererType) \
float alteredIconScale=1.f; \ 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}); std::get<rendererType*const>(renderer)->DrawDecal(pos+offset-vf2d{0.f,2.f},img,alteredIconScale*textScale,{255,255,255,alpha});
#pragma endregion #pragma endregion
if(std::holds_alternative<AiL*const>(renderer)){ 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); 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{ const bool Input::HasIcon()const{
if(type==STEAM){ if(type==STEAM){
return Input::steamGameInputToOrigin.count(Steam::SteamInput(key))&& return Input::steamGameInputToOrigin.count(Steam::SteamInput(key))&&
@ -816,8 +855,12 @@ const bool Input::HasExtendedIcons()const{
const Renderable&Input::GetIcon()const{ const Renderable&Input::GetIcon()const{
if(type==STEAM){ if(type==STEAM){
EInputActionOrigin action=Input::steamGameInputToOrigin.at(Steam::SteamInput(key)).second[0]; 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(SteamInput()->GetGlyphPNGForActionOrigin(action,k_ESteamInputGlyphSize_Small,0));
} }
}
return GFX.at(GenericKey::keyLiteral.at({type,key}).iconName); return GFX.at(GenericKey::keyLiteral.at({type,key}).iconName);
} }
const Renderable&Input::GetIcon(IconType type)const{ const Renderable&Input::GetIcon(IconType type)const{

@ -137,6 +137,7 @@ public:
const Renderable&GetIcon(IconType type)const; const Renderable&GetIcon(IconType type)const;
const int GetKeyCode()const; const int GetKeyCode()const;
friend const bool operator==(const Input&input1,const Input&input2); friend const bool operator==(const Input&input1,const Input&input2);
std::string GetProperIconName(std::string currentIconName)const;
static uint64_t ingameControlsHandle; static uint64_t ingameControlsHandle;
}; };

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 5 #define VERSION_MINOR 5
#define VERSION_PATCH 1 #define VERSION_PATCH 1
#define VERSION_BUILD 8330 #define VERSION_BUILD 8336
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

Loading…
Cancel
Save