@ -75,6 +75,7 @@ void InputHelper::Draw(){
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 ( ) ) ;
}
@ -87,32 +88,39 @@ void InputHelper::Draw(){
float buttonDescriptionScaleX = 1.0f ;
if ( buttonImgWidth + buttonDescriptionWidth > WINDOW_SIZE . x ) {
buttonDescriptionScaleX = ( WINDOW_SIZE . x - buttonImgWidth ) / ( buttonDescriptionWidth + buttonImg Width ) ;
if ( buttonImgWidth + buttonDescriptionWidth > WINDOW_SIZE . x - " Interface.InputHelperSpacing " _I ) {
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
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 ) - 8 } , img ) ;
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 - 10 ) } , 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 - 10 ) } , 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 - > 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 - 10 ) } , description , WHITE , BLACK , vf2d { buttonDescriptionScaleX , 1.f } ) ;
xOffset + = descriptionTextSize . x + " Interface.InputHelperSpacing " _I ;
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 + + ;
}