@ -52,72 +52,72 @@ void Menu::InitializeLoadGameWindow(){
# define ScrollWindow(amount) \
[ ] ( MenuType type ) { \
auto scrollWindow = Component < ScrollableWindowComponent > ( type , " Game Files List " ) ; \
float scrollAmt = amount * game - > GetElapsedTime ( ) * " Interface.AnalogScrollSpeed " _F ; \
\
scrollWindow - > SetScrollAmount ( scrollWindow - > GetTargetScrollAmount ( ) - vf2d { 0 , amount * game - > GetElapsedTime ( ) * " Interface.AnalogScrollSpeed " _F } ) ; \
\
scrollWindow - > Scroll ( amount ) ; \
float scrollAmt = amount * game - > GetElapsedTime ( ) * " Interface.AnalogScrollSpeed " _F ; \
/*Height of these buttons is 48.*/ \
scrollWindow - > IncreaseSelectionIndex ( scrollAmt / 48.f ) ; \
}
# pragma endregion
loadGameWindow - > SetupKeyboardNavigation (
[ ] ( MenuType type , Data & returnData ) { //On Open
if ( SaveFile : : GetSaveFileCount ( ) > 0 ) {
returnData = Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) [ 0 ] ;
} else {
returnData = " Go Back Button " ;
# pragma region Keyboard Navigation Rules
loadGameWindow - > SetupKeyboardNavigation (
[ ] ( MenuType type , Data & returnData ) { //On Open
if ( SaveFile : : GetSaveFileCount ( ) > 0 ) {
returnData = Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) [ 0 ] ;
} else {
returnData = " Go Back Button " ;
}
} ,
{ //Button Key
{ { game - > KEY_BACK } , { " Back to Title Screen " , [ ] ( MenuType type ) {
Component < MenuComponent > ( type , " Go Back Button " ) - > Click ( ) ;
} } } ,
{ { game - > KEY_SCROLL , Analog } , { " Scroll " , ScrollWindow ( game - > KEY_SCROLL . Analog ( ) ) } } ,
{ { game - > KEY_SCROLLUP , Held } , { " Scroll Up " , ScrollWindow ( - 1.0f ) } } ,
{ { game - > KEY_SCROLLDOWN , Held } , { " Scroll Down " , ScrollWindow ( 1.0f ) } } ,
}
} ,
{ //Button Key
{ { game - > KEY_BACK } , { " Back to Title Screen " , [ ] ( MenuType type ) {
Component < MenuComponent > ( type , " Go Back Button " ) - > Click ( ) ;
} } } ,
{ { game - > KEY_SCROLL , Analog } , { " Scroll " , ScrollWindow ( game - > KEY_SCROLL . Analog ( ) ) } } ,
{ { game - > KEY_SCROLLUP , Held } , { " Scroll Up " , ScrollWindow ( - 1.0f ) } } ,
{ { game - > KEY_SCROLLDOWN , Held } , { " Scroll Down " , ScrollWindow ( 1.0f ) } } ,
}
, { //Button Navigation Rules
{ " Game Files List " , {
. up = [ ] ( MenuType type , Data & returnData ) {
auto & selection = Menu : : menus [ type ] - > GetSelection ( ) ;
auto & gameFilesList = Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) ;
auto component = std : : find_if ( gameFilesList . begin ( ) , gameFilesList . end ( ) , [ & ] ( auto & comp ) { return comp . lock ( ) = = selection . lock ( ) ; } ) ;
if ( component = = gameFilesList . begin ( ) ) {
returnData = " Go Back Button " ;
} else {
returnData = * ( - - component ) ;
}
} ,
. down = [ ] ( MenuType type , Data & returnData ) {
auto & selection = Menu : : menus [ type ] - > GetSelection ( ) ;
auto & gameFilesList = Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) ;
auto component = std : : find_if ( gameFilesList . begin ( ) , gameFilesList . end ( ) , [ & ] ( auto & comp ) { return comp . lock ( ) = = selection . lock ( ) ; } ) ;
if ( component = = gameFilesList . end ( ) - 1 ) {
returnData = " Go Back Button " ;
} else {
returnData = * ( + + component ) ;
}
} , } } ,
{ " Go Back Button " , {
. up = [ ] ( MenuType type , Data & returnData ) {
auto & selection = Menu : : menus [ type ] - > GetSelection ( ) ;
auto & gameFilesList = Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) ;
if ( gameFilesList . size ( ) = = 0 ) {
returnData = " Go Back Button " ;
return ;
}
returnData = * ( gameFilesList . end ( ) - 1 ) ;
} ,
. down = [ ] ( MenuType type , Data & returnData ) {
auto & selection = Menu : : menus [ type ] - > GetSelection ( ) ;
auto & gameFilesList = Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) ;
if ( gameFilesList . size ( ) = = 0 ) {
returnData = " Go Back Button " ;
return ;
}
returnData = * ( gameFilesList . begin ( ) ) ;
} ,
} } ,
} ) ;
, { //Button Navigation Rules
{ " Game Files List " , {
. up = [ ] ( MenuType type , Data & returnData ) {
auto & selection = Menu : : menus [ type ] - > GetSelection ( ) ;
auto & gameFilesList = Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) ;
auto component = std : : find_if ( gameFilesList . begin ( ) , gameFilesList . end ( ) , [ & ] ( auto & comp ) { return comp . lock ( ) = = selection . lock ( ) ; } ) ;
if ( component = = gameFilesList . begin ( ) ) {
returnData = " Go Back Button " ;
} else {
returnData = * ( - - component ) ;
}
} ,
. down = [ ] ( MenuType type , Data & returnData ) {
auto & selection = Menu : : menus [ type ] - > GetSelection ( ) ;
auto & gameFilesList = Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) ;
auto component = std : : find_if ( gameFilesList . begin ( ) , gameFilesList . end ( ) , [ & ] ( auto & comp ) { return comp . lock ( ) = = selection . lock ( ) ; } ) ;
if ( component = = gameFilesList . end ( ) - 1 ) {
returnData = " Go Back Button " ;
} else {
returnData = * ( + + component ) ;
}
} , } } ,
{ " Go Back Button " , {
. up = [ ] ( MenuType type , Data & returnData ) {
auto & selection = Menu : : menus [ type ] - > GetSelection ( ) ;
auto & gameFilesList = Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) ;
if ( gameFilesList . size ( ) = = 0 ) {
returnData = " Go Back Button " ;
return ;
}
returnData = * ( gameFilesList . end ( ) - 1 ) ;
} ,
. down = [ ] ( MenuType type , Data & returnData ) {
auto & selection = Menu : : menus [ type ] - > GetSelection ( ) ;
auto & gameFilesList = Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) ;
if ( gameFilesList . size ( ) = = 0 ) {
returnData = " Go Back Button " ;
return ;
}
returnData = * ( gameFilesList . begin ( ) ) ;
} ,
} } ,
} ) ;
# pragma endregion
}