@ -48,6 +48,9 @@ INCLUDE_WINDOW_SIZE
InputHelper : : InputHelper ( ) { }
InputHelper : : InputHelper ( ) { }
void InputHelper : : Initialize ( MenuInputGroups & inputGroups ) {
void InputHelper : : Initialize ( MenuInputGroups & inputGroups ) {
groupData . clear ( ) ; //HACK ALERT: WTF, somehow we must clear this map because there are references to things that are mixed up where they shouldn't be
// ONLY for the emscripten build. Clearing this map ensures that we start with fresh copies to things and it appears that emscripten
// likes this...?
groupData = inputGroups ;
groupData = inputGroups ;
}
}
@ -70,25 +73,24 @@ void InputHelper::Draw(){
# pragma region Populate all buttons to display
# pragma region Populate all buttons to display
inputGroups . clear ( ) ;
inputGroups . clear ( ) ;
groupedInputs . clear ( ) ;
groupedInputs . clear ( ) ;
for ( auto & data : groupData ) {
for ( auto & [ group , action ] : groupData ) {
if ( data . first . GetLabelVisible ( ) ) { //If the label is not visible, we don't care to include it in our list.
if ( group . 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 ) ) {
if ( std : : holds_alternative < ButtonName > ( action . first ) ) {
const ButtonName & name = std : : get < ButtonName > ( data . second . first ) ;
const ButtonName & name = std : : get < ButtonName > ( action . first ) ;
groupedInputs [ name ] . push_back ( data . first . GetGroup ( ) ) ;
groupedInputs [ name ] . push_back ( group . GetGroup ( ) ) ;
if ( groupedInputs [ name ] . size ( ) > 1 ) continue ; //Skip adding to the list of input groups because this input already has been added.
if ( groupedInputs [ name ] . size ( ) > 1 ) continue ; //Skip adding to the list of input groups because this input already has been added.
} else
} else
if ( std : : holds_alternative < std : : function < std : : string ( MenuFuncData ) > > ( data . second . first ) ) {
if ( std : : holds_alternative < std : : function < std : : string ( MenuFuncData ) > > ( action . first ) ) {
std : : weak_ptr < ScrollableWindowComponent > parentComponent ;
std : : weak_ptr < ScrollableWindowComponent > parentComponent ;
if ( ! Menu : : stack . back ( ) - > GetSelection ( ) . expired ( ) ) {
if ( ! Menu : : stack . back ( ) - > GetSelection ( ) . expired ( ) ) {
parentComponent = Menu : : stack . back ( ) - > GetSelection ( ) . lock ( ) - > parentComponent ;
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 } ) ;
std : : string name = std : : get < std : : function < std : : string ( MenuFuncData ) > > ( action . first ) ( MenuFuncData { * Menu : : stack . back ( ) , game , Menu : : stack . back ( ) - > GetSelection ( ) , parentComponent } ) ;
groupedInputs [ name ] . push_back ( data . first . GetGroup ( ) ) ;
groupedInputs [ name ] . push_back ( group . GetGroup ( ) ) ;
if ( groupedInputs [ name ] . size ( ) > 1 ) continue ; //Skip adding to the list of input groups because this input already has been added.
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 ;
this - > inputGroups [ group . GetGroup ( ) ] = action . first ;
}
}
}
}
for ( auto & [ group , display ] : inputGroups ) {
for ( auto & [ group , display ] : inputGroups ) {