@ -50,35 +50,44 @@ void Menu::InitializeLoadGameWindow(){
loadGameWindow - > ADD ( " Online Game Files List " , ScrollableWindowComponent ) ( geom2d : : rect < float > { { 40 , 24 } , { 112 , 116 } } ) END
- > Disable ( ) ;
loadGameWindow - > ADD ( " Go Back Button " , MenuComponent ) ( geom2d : : rect < float > { { 72 , 148 } , { 48 , 12 } } , " Back " , [ ] ( MenuFuncData menu ) { Menu : : CloseMenu ( ) ; return true ; } ) END ;
# ifdef __EMSCRIPTEN__
auto offlineCharacterTab = loadGameWindow - > ADD ( " Offline Character Tab " , MenuComponent ) ( geom2d : : rect < float > { { - 8 , 4 } , { 102 , 16 } } , " Offline Characters " , [ ] ( MenuFuncData data ) {
Component < ScrollableWindowComponent > ( data . menu . GetType ( ) , " Game Files List " ) - > Enable ( ) ;
Component < ScrollableWindowComponent > ( data . menu . GetType ( ) , " Online Game Files List " ) - > Disable ( ) ;
Component < MenuComponent > ( data . menu . GetType ( ) , " Online Character Tab " ) - > SetSelected ( false ) ;
data . component . lock ( ) - > SetSelected ( true ) ;
SoundEffect : : PlaySFX ( " Button Click " , SoundEffect : : CENTERED ) ;
SaveFile : : SetOnlineMode ( false ) ;
return true ;
} , ButtonAttr : : FIT_TO_LABEL ) END ;
offlineCharacterTab - > SetSelectionType ( HIGHLIGHT ) ;
offlineCharacterTab - > SetSelected ( true ) ;
auto onlineCharacterTab = loadGameWindow - > ADD ( " Online Character Tab " , MenuComponent ) ( geom2d : : rect < float > { { 96 , 4 } , { 102 , 16 } } , " Online Characters " , [ ] ( MenuFuncData data ) {
Component < ScrollableWindowComponent > ( data . menu . GetType ( ) , " Game Files List " ) - > Disable ( ) ;
Component < ScrollableWindowComponent > ( data . menu . GetType ( ) , " Online Game Files List " ) - > Enable ( ) ;
Component < MenuComponent > ( data . menu . GetType ( ) , " Offline Character Tab " ) - > SetSelected ( false ) ;
SoundEffect : : PlaySFX ( " Button Click " , SoundEffect : : CENTERED ) ;
data . component . lock ( ) - > SetSelected ( true ) ;
if ( ! SaveFile : : IsOnline ( ) ) {
if ( SaveFile : : GetUserID ( ) . length ( ) = = 0 ) {
//Present the user with the user ID form.
game - > TextEntryEnable ( true ) ;
Menu : : OpenMenu ( USER_ID ) ;
}
SaveFile : : SetOnlineMode ( true ) ;
auto offlineCharacterTab = loadGameWindow - > ADD ( " Offline Character Tab " , MenuComponent ) ( geom2d : : rect < float > { { - 8 , 4 } , { 102 , 16 } } , " Offline Characters " , [ ] ( MenuFuncData data ) {
Component < ScrollableWindowComponent > ( data . menu . GetType ( ) , " Game Files List " ) - > Enable ( ) ;
Component < ScrollableWindowComponent > ( data . menu . GetType ( ) , " Online Game Files List " ) - > Disable ( ) ;
Component < MenuComponent > ( data . menu . GetType ( ) , " Online Character Tab " ) - > SetSelected ( false ) ;
data . component . lock ( ) - > SetSelected ( true ) ;
SoundEffect : : PlaySFX ( " Button Click " , SoundEffect : : CENTERED ) ;
SaveFile : : SetOnlineMode ( false ) ;
if ( Component < ScrollableWindowComponent > ( data . menu . GetType ( ) , " Game Files List " ) - > GetComponents ( ) . size ( ) > 0 ) {
data . menu . SetSelection ( Component < ScrollableWindowComponent > ( data . menu . GetType ( ) , " Game Files List " ) - > GetComponents ( ) [ 0 ] , true ) ;
}
return true ;
} , ButtonAttr : : FIT_TO_LABEL ) END ;
offlineCharacterTab - > SetSelectionType ( HIGHLIGHT ) ;
offlineCharacterTab - > SetSelected ( true ) ;
auto onlineCharacterTab = loadGameWindow - > ADD ( " Online Character Tab " , MenuComponent ) ( geom2d : : rect < float > { { 96 , 4 } , { 102 , 16 } } , " Online Characters " , [ ] ( MenuFuncData data ) {
Component < ScrollableWindowComponent > ( data . menu . GetType ( ) , " Game Files List " ) - > Disable ( ) ;
Component < ScrollableWindowComponent > ( data . menu . GetType ( ) , " Online Game Files List " ) - > Enable ( ) ;
Component < MenuComponent > ( data . menu . GetType ( ) , " Offline Character Tab " ) - > SetSelected ( false ) ;
SoundEffect : : PlaySFX ( " Button Click " , SoundEffect : : CENTERED ) ;
data . component . lock ( ) - > SetSelected ( true ) ;
if ( ! SaveFile : : IsOnline ( ) ) {
if ( SaveFile : : GetUserID ( ) . length ( ) = = 0 ) {
//Present the user with the user ID form.
game - > TextEntryEnable ( true ) ;
Menu : : OpenMenu ( USER_ID ) ;
}
return true ;
} , ButtonAttr : : FIT_TO_LABEL ) END ;
onlineCharacterTab - > SetSelectionType ( HIGHLIGHT ) ;
SaveFile : : SetOnlineMode ( true ) ;
}
if ( Component < ScrollableWindowComponent > ( data . menu . GetType ( ) , " Online Game Files List " ) - > GetComponents ( ) . size ( ) > 0 ) {
data . menu . SetSelection ( Component < ScrollableWindowComponent > ( data . menu . GetType ( ) , " Online Game Files List " ) - > GetComponents ( ) [ 0 ] , true ) ;
}
return true ;
} , ButtonAttr : : FIT_TO_LABEL ) END ;
onlineCharacterTab - > SetSelectionType ( HIGHLIGHT ) ;
# ifndef __EMSCRIPTEN__
offlineCharacterTab - > Disable ( ) ;
onlineCharacterTab - > Disable ( ) ;
# endif
# pragma region Keyboard Navigation Rules
@ -86,9 +95,19 @@ void Menu::InitializeLoadGameWindow(){
[ ] ( MenuType type , Data & returnData ) { //On Open
if ( SaveFile : : GetSaveFileCount ( ) > 0 | | SaveFile : : GetOnlineSaveFileCount ( ) > 0 ) {
if ( SaveFile : : IsOnline ( ) ) {
returnData = Component < ScrollableWindowComponent > ( type , " Online Game Files List " ) - > GetComponents ( ) [ 0 ] ;
if ( Component < ScrollableWindowComponent > ( type , " Online Game Files List " ) - > GetComponents ( ) . size ( ) > 0 ) {
Menu : : menus [ type ] - > SetSelection ( Component < ScrollableWindowComponent > ( type , " Online Game Files List " ) - > GetComponents ( ) [ 0 ] , true ) ;
returnData = Menu : : menus [ type ] - > GetSelection ( ) ;
} else {
returnData = " Go Back Button " ;
}
} else {
returnData = Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) [ 0 ] ;
if ( Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) . size ( ) > 0 ) {
Menu : : menus [ type ] - > SetSelection ( Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) [ 0 ] , true ) ;
returnData = Menu : : menus [ type ] - > GetSelection ( ) ;
} else {
returnData = " Go Back Button " ;
}
}
} else {
returnData = " Go Back Button " ;
@ -98,6 +117,21 @@ void Menu::InitializeLoadGameWindow(){
{ { game - > KEY_BACK } , { " Back to Title Screen " , [ ] ( MenuType type ) {
Component < MenuComponent > ( type , " Go Back Button " ) - > Click ( ) ;
} } } ,
# ifdef __EMSCRIPTEN__
{ { game - > KEY_FACELEFT } , { [ ] ( MenuFuncData data ) {
if ( Component < MenuComponent > ( data . menu . GetType ( ) , " Offline Character Tab " ) - > selected ) {
return " Online Characters " ;
} else {
return " Offline Characters " ;
}
} , [ ] ( MenuType type ) {
if ( Component < MenuComponent > ( type , " Offline Character Tab " ) - > selected ) {
Component < MenuComponent > ( type , " Online Character Tab " ) - > Click ( ) ;
} else {
Component < MenuComponent > ( type , " Offline Character Tab " ) - > Click ( ) ;
}
} } } ,
# endif
{ { game - > KEY_CONFIRM } , { " Load " , [ ] ( MenuType type ) { } } } ,
{ { game - > KEY_SCROLLVERT , Analog } , { " Scroll " , [ ] ( MenuType type ) { } } } ,
{ { game - > KEY_SHOULDER , Pressed } , { " Scroll " , [ ] ( MenuType type ) { } } } ,
@ -131,26 +165,187 @@ void Menu::InitializeLoadGameWindow(){
} else {
returnData = * ( + + component ) ;
}
} , } } ,
} ,
# ifdef __EMSCRIPTEN__
. left = [ ] ( MenuType type , Data & returnData ) {
Component < MenuComponent > ( type , " Online Character Tab " ) - > Click ( ) ;
if ( Menu : : menus [ type ] - > GetSelection ( ) . expired ( ) ) {
returnData = " Go Back Button " ;
} else {
returnData = Menu : : menus [ type ] - > GetSelection ( ) ;
}
} ,
. right = [ ] ( MenuType type , Data & returnData ) {
Component < MenuComponent > ( type , " Online Character Tab " ) - > Click ( ) ;
if ( Menu : : menus [ type ] - > GetSelection ( ) . expired ( ) ) {
returnData = " Go Back Button " ;
} else {
returnData = Menu : : menus [ type ] - > GetSelection ( ) ;
}
} ,
# endif
} } ,
{ " Online Game Files List " , {
. up = [ ] ( MenuType type , Data & returnData ) {
auto & selection = Menu : : menus [ type ] - > GetSelection ( ) ;
auto & gameFilesList = Component < ScrollableWindowComponent > ( type , " Online 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 , " Online 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 ) ;
}
} ,
# ifdef __EMSCRIPTEN__
. left = [ ] ( MenuType type , Data & returnData ) {
Component < MenuComponent > ( type , " Offline Character Tab " ) - > Click ( ) ;
if ( Menu : : menus [ type ] - > GetSelection ( ) . expired ( ) ) {
returnData = " Go Back Button " ;
} else {
returnData = Menu : : menus [ type ] - > GetSelection ( ) ;
}
} ,
. right = [ ] ( MenuType type , Data & returnData ) {
Component < MenuComponent > ( type , " Offline Character Tab " ) - > Click ( ) ;
if ( Menu : : menus [ type ] - > GetSelection ( ) . expired ( ) ) {
returnData = " Go Back Button " ;
} else {
returnData = Menu : : menus [ type ] - > GetSelection ( ) ;
}
} ,
# endif
} } ,
{ " 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 ) {
std : : vector < std : : weak_ptr < MenuComponent > > * gameFilesList = & Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) ;
if ( ! Component < MenuComponent > ( type , " Offline Character Tab " ) - > selected ) {
gameFilesList = & Component < ScrollableWindowComponent > ( type , " Online Game Files List " ) - > GetComponents ( ) ;
}
if ( gameFilesList - > size ( ) = = 0 ) {
returnData = " Go Back Button " ;
return ;
}
returnData = * ( gameFilesList . end ( ) - 1 ) ;
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 ) {
std : : vector < std : : weak_ptr < MenuComponent > > * gameFilesList = & Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) ;
if ( ! Component < MenuComponent > ( type , " Offline Character Tab " ) - > selected ) {
gameFilesList = & Component < ScrollableWindowComponent > ( type , " Online Game Files List " ) - > GetComponents ( ) ;
}
if ( gameFilesList - > size ( ) = = 0 ) {
returnData = " Go Back Button " ;
return ;
}
returnData = * ( gameFilesList - > begin ( ) ) ;
} ,
# ifdef __EMSCRIPTEN__
. left = [ ] ( MenuType type , Data & returnData ) {
if ( ! Component < MenuComponent > ( type , " Offline Character Tab " ) - > selected ) {
Component < MenuComponent > ( type , " Offline Character Tab " ) - > Click ( ) ;
} else {
Component < MenuComponent > ( type , " Online Character Tab " ) - > Click ( ) ;
}
if ( Menu : : menus [ type ] - > GetSelection ( ) . expired ( ) ) {
returnData = " Go Back Button " ;
} else {
returnData = Menu : : menus [ type ] - > GetSelection ( ) ;
}
} ,
. right = [ ] ( MenuType type , Data & returnData ) {
if ( ! Component < MenuComponent > ( type , " Offline Character Tab " ) - > selected ) {
Component < MenuComponent > ( type , " Offline Character Tab " ) - > Click ( ) ;
} else {
Component < MenuComponent > ( type , " Online Character Tab " ) - > Click ( ) ;
}
if ( Menu : : menus [ type ] - > GetSelection ( ) . expired ( ) ) {
returnData = " Go Back Button " ;
} else {
returnData = Menu : : menus [ type ] - > GetSelection ( ) ;
}
} ,
# endif
} } ,
{ " Offline Character Tab " , {
. up = [ ] ( MenuType type , Data & returnData ) {
returnData = " Go Back Button " ;
} ,
. down = [ ] ( MenuType type , Data & returnData ) {
auto & selection = Menu : : menus [ type ] - > GetSelection ( ) ;
std : : vector < std : : weak_ptr < MenuComponent > > * gameFilesList = & Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) ;
if ( ! Component < MenuComponent > ( type , " Offline Character Tab " ) - > selected ) {
gameFilesList = & Component < ScrollableWindowComponent > ( type , " Online Game Files List " ) - > GetComponents ( ) ;
}
if ( gameFilesList - > size ( ) = = 0 ) {
returnData = " Go Back Button " ;
return ;
}
returnData = * ( gameFilesList . begin ( ) ) ;
returnData = * ( gameFilesList - > begin ( ) ) ;
} ,
# ifdef __EMSCRIPTEN__
. left = [ ] ( MenuType type , Data & returnData ) {
Component < MenuComponent > ( type , " Online Character Tab " ) - > Click ( ) ;
if ( Menu : : menus [ type ] - > GetSelection ( ) . expired ( ) ) {
returnData = " Go Back Button " ;
} else {
returnData = Menu : : menus [ type ] - > GetSelection ( ) ;
}
} ,
. right = [ ] ( MenuType type , Data & returnData ) {
Component < MenuComponent > ( type , " Online Character Tab " ) - > Click ( ) ;
if ( Menu : : menus [ type ] - > GetSelection ( ) . expired ( ) ) {
returnData = " Go Back Button " ;
} else {
returnData = Menu : : menus [ type ] - > GetSelection ( ) ;
}
} ,
# endif
} } ,
{ " Online Character Tab " , {
. up = [ ] ( MenuType type , Data & returnData ) {
returnData = " Go Back Button " ;
} ,
. down = [ ] ( MenuType type , Data & returnData ) {
auto & selection = Menu : : menus [ type ] - > GetSelection ( ) ;
std : : vector < std : : weak_ptr < MenuComponent > > * gameFilesList = & Component < ScrollableWindowComponent > ( type , " Game Files List " ) - > GetComponents ( ) ;
if ( ! Component < MenuComponent > ( type , " Offline Character Tab " ) - > selected ) {
gameFilesList = & Component < ScrollableWindowComponent > ( type , " Online Game Files List " ) - > GetComponents ( ) ;
}
if ( gameFilesList - > size ( ) = = 0 ) {
returnData = " Go Back Button " ;
return ;
}
returnData = * ( gameFilesList - > begin ( ) ) ;
} ,
# ifdef __EMSCRIPTEN__
. left = [ ] ( MenuType type , Data & returnData ) {
Component < MenuComponent > ( type , " Offline Character Tab " ) - > Click ( ) ;
if ( Menu : : menus [ type ] - > GetSelection ( ) . expired ( ) ) {
returnData = " Go Back Button " ;
} else {
returnData = Menu : : menus [ type ] - > GetSelection ( ) ;
}
} ,
. right = [ ] ( MenuType type , Data & returnData ) {
Component < MenuComponent > ( type , " Offline Character Tab " ) - > Click ( ) ;
if ( Menu : : menus [ type ] - > GetSelection ( ) . expired ( ) ) {
returnData = " Go Back Button " ;
} else {
returnData = Menu : : menus [ type ] - > GetSelection ( ) ;
}
} ,
# endif
} } ,
} ) ;
# pragma endregion