@ -49,17 +49,7 @@ InputHelper::InputHelper(){}
void InputHelper : : Initialize ( MenuInputGroups & inputGroups ) {
this - > inputGroups . clear ( ) ;
for ( auto & data : inputGroups ) {
if ( data . first . GetLabelVisible ( ) ) { //If the label is not visible, we don't care to include it in our list.
if ( std : : holds_alternative < ButtonName > ( data . second . first ) ) {
const ButtonName & name = std : : get < ButtonName > ( data . second . first ) ;
groupedInputs [ name ] . push_back ( data . first . GetGroup ( ) ) ;
if ( groupedInputs [ name ] . size ( ) > 1 ) continue ; //Skip adding to the list of input groups because this input already has been added.
}
this - > inputGroups [ data . first . GetGroup ( ) ] = data . second . first ;
}
}
groupData = inputGroups ;
}
const InputType InputHelper : : InputMode ( ) const {
@ -79,32 +69,73 @@ void InputHelper::Draw(){
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 : : string > buttonDescriptions ;
# pragma region Populate all buttons to display
inputGroups . clear ( ) ;
groupedInputs . clear ( ) ;
for ( auto & data : groupData ) {
if ( data . first . GetLabelVisible ( ) ) { //If the label is not visible, we don't care to include it in our list.
if ( std : : holds_alternative < ButtonName > ( data . second . first ) ) {
const ButtonName & name = std : : get < ButtonName > ( data . second . first ) ;
groupedInputs [ name ] . push_back ( data . first . GetGroup ( ) ) ;
if ( groupedInputs [ name ] . size ( ) > 1 ) continue ; //Skip adding to the list of input groups because this input already has been added.
} else
if ( std : : holds_alternative < std : : function < std : : string ( MenuFuncData ) > > ( data . second . first ) ) {
std : : weak_ptr < ScrollableWindowComponent > parentComponent ;
if ( ! Menu : : stack . back ( ) - > GetSelection ( ) . expired ( ) ) {
parentComponent = Menu : : stack . back ( ) - > GetSelection ( ) . lock ( ) - > parentComponent ;
}
std : : string name = std : : get < std : : function < std : : string ( MenuFuncData ) > > ( data . second . first ) ( MenuFuncData { * Menu : : stack . back ( ) , game , Menu : : stack . back ( ) - > GetSelection ( ) , parentComponent } ) ;
groupedInputs [ name ] . push_back ( data . first . GetGroup ( ) ) ;
if ( groupedInputs [ name ] . size ( ) > 1 ) continue ; //Skip adding to the list of input groups because this input already has been added.
}
this - > inputGroups [ data . first . GetGroup ( ) ] = data . second . first ;
}
}
for ( auto & [ group , display ] : inputGroups ) {
size_t groupedInputCount = 1 ;
std : : vector < InputGroup > inputGroupsToCheck ;
if ( std : : holds_alternative < std : : string > ( display ) & & groupedInputs . count ( std : : get < std : : string > ( display ) ) ) {
inputGroupsToCheck = groupedInputs . at ( std : : get < std : : string > ( display ) ) ;
} else {
inputGroupsToCheck . push_back ( group ) ;
std : : weak_ptr < ScrollableWindowComponent > parentComponent ;
if ( ! Menu : : stack . back ( ) - > GetSelection ( ) . expired ( ) ) {
parentComponent = Menu : : stack . back ( ) - > GetSelection ( ) . lock ( ) - > parentComponent ;
}
std : : vector < InputGroup > inputGroupsToCheck ;
std : : string displayName ;
if ( std : : holds_alternative < std : : string > ( display ) ) displayName = std : : get < std : : string > ( display ) ;
else
if ( std : : holds_alternative < std : : function < std : : string ( MenuFuncData ) > > ( display ) ) {
std : : weak_ptr < ScrollableWindowComponent > parentComponent ;
if ( ! Menu : : stack . back ( ) - > GetSelection ( ) . expired ( ) ) {
parentComponent = Menu : : stack . back ( ) - > GetSelection ( ) . lock ( ) - > parentComponent ;
}
displayName = std : : get < std : : function < std : : string ( MenuFuncData ) > > ( display ) ( MenuFuncData { * Menu : : stack . back ( ) , game , Menu : : stack . back ( ) - > GetSelection ( ) , parentComponent } ) ;
}
else ERR ( " WARNING! display contains a variant alternative that does not exist. THIS SHOULD NOT BE HAPPENING! " ) ;
if ( groupedInputs . count ( displayName ) ) {
inputGroupsToCheck = groupedInputs . at ( displayName ) ;
} else {
inputGroupsToCheck . push_back ( group ) ;
}
buttonImgs . push_back ( { } ) ;
std : : vector < std : : variant < Decal * , std : : string > > & iconList = buttonImgs . back ( ) ;
for ( InputGroup & group : inputGroupsToCheck ) {
if ( Menu : : UsingMouseNavigation ( ) ) {
auto & primaryKey = group . GetPrimaryKey ( MOUSE ) ;
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 ( ) ) ;
} else
if ( primaryKey . value ( ) . HasIcon ( ) ) {
buttonImgWidth + = primaryKey . value ( ) . GetIcon ( ) . Sprite ( ) - > width + " Interface.InputHelperSpacing " _I ;
iconList . push_back ( primaryKey . value ( ) . GetIcon ( ) . Decal ( ) ) ;
} else {
buttonImgWidth + = game - > GetTextSizeProp ( primaryKey . value ( ) . GetDisplayName ( ) ) . x + " Interface.InputHelperSpacing " _I ;
iconList . push_back ( primaryKey . value ( ) . GetDisplayName ( ) ) ;
}
}
}
auto & primaryKey = group . GetPrimaryKey ( mode ) ;
if ( displayName . length ( ) > 0 & & primaryKey . has_value ( ) ) {