diff --git a/Adventures in Lestoria/ClassSelectionWindow.cpp b/Adventures in Lestoria/ClassSelectionWindow.cpp index c161f37a..8f7e18e1 100644 --- a/Adventures in Lestoria/ClassSelectionWindow.cpp +++ b/Adventures in Lestoria/ClassSelectionWindow.cpp @@ -195,6 +195,11 @@ void Menu::InitializeClassSelectionWindow(){ {game->KEY_FACEUP,{"Change Player Name",[](MenuType type){ Component(type,"Character Name Box")->Click(); }}}, + #ifdef __EMSCRIPTEN__ + {game->KEY_FACELEFT,{"Toggle Online Character",[](MenuType type){ + Component(type,"Online Character Checkbox")->Click(); + }}}, + #endif } ,{ //Button Navigation Rules {Warrior::name+" Button",{ @@ -225,13 +230,21 @@ void Menu::InitializeClassSelectionWindow(){ .up=Wizard::name+" Icon", .down=Witch::name+" Icon", .left=Ranger::name+" Button", - .right="Confirm", + #ifdef __EMSCRIPTEN__ + .right="Online Character Checkbox", + #else + .right="Confirm", + #endif }}, {Wizard::name+" Icon",{ .up="Character Name Box", .down=Wizard::name+" Button", .left=Ranger::name+" Icon", - .right="Confirm", + #ifdef __EMSCRIPTEN__ + .right="Online Character Checkbox", + #else + .right="Confirm", + #endif }}, {Thief::name+" Button",{ .up=Thief::name+" Icon", @@ -261,24 +274,42 @@ void Menu::InitializeClassSelectionWindow(){ .up=Witch::name+" Icon", .down="Character Name Box", .left=Trapper::name+" Button", - .right="Confirm", + #ifdef __EMSCRIPTEN__ + .right="Online Character Checkbox", + #else + .right="Confirm", + #endif }}, {Witch::name+" Icon",{ .up=Wizard::name+" Button", .down=Witch::name+" Button", .left=Trapper::name+" Icon", - .right="Confirm", + #ifdef __EMSCRIPTEN__ + .right="Online Character Checkbox", + #else + .right="Confirm", + #endif }}, {"Character Name Box",{ .up=Witch::name+" Button", .down=Wizard::name+" Icon", }}, {"Confirm",{ - .up=Wizard::name+" Button", + #ifdef __EMSCRIPTEN__ + .up="Online Character Checkbox", + #else + .up=Wizard::name+" Button", + #endif .down=Wizard::name+" Button", .left=Wizard::name+" Button", .right="Back", }}, + {"Online Character Checkbox",{ + .up="Confirm", + .down="Confirm", + .left=Wizard::name+" Button", + .right=Warrior::name+" Button", + }}, {"Back",{ .up=Warrior::name+" Button", .down=Warrior::name+" Button", diff --git a/Adventures in Lestoria/LoadGameWindow.cpp b/Adventures in Lestoria/LoadGameWindow.cpp index d5f8d9f3..51c64414 100644 --- a/Adventures in Lestoria/LoadGameWindow.cpp +++ b/Adventures in Lestoria/LoadGameWindow.cpp @@ -50,35 +50,44 @@ void Menu::InitializeLoadGameWindow(){ loadGameWindow->ADD("Online Game Files List",ScrollableWindowComponent)(geom2d::rect{{40,24},{112,116}})END ->Disable(); loadGameWindow->ADD("Go Back Button",MenuComponent)(geom2d::rect{{72,148},{48,12}},"Back",[](MenuFuncData menu){Menu::CloseMenu();return true;})END; - #ifdef __EMSCRIPTEN__ - auto offlineCharacterTab = loadGameWindow->ADD("Offline Character Tab",MenuComponent)(geom2d::rect{{-8,4},{102,16}},"Offline Characters",[](MenuFuncData data){ - Component(data.menu.GetType(),"Game Files List")->Enable(); - Component(data.menu.GetType(),"Online Game Files List")->Disable(); - Component(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{{96,4},{102,16}},"Online Characters",[](MenuFuncData data){ - Component(data.menu.GetType(),"Game Files List")->Disable(); - Component(data.menu.GetType(),"Online Game Files List")->Enable(); - Component(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{{-8,4},{102,16}},"Offline Characters",[](MenuFuncData data){ + Component(data.menu.GetType(),"Game Files List")->Enable(); + Component(data.menu.GetType(),"Online Game Files List")->Disable(); + Component(data.menu.GetType(),"Online Character Tab")->SetSelected(false); + data.component.lock()->SetSelected(true); + SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED); + SaveFile::SetOnlineMode(false); + if(Component(data.menu.GetType(),"Game Files List")->GetComponents().size()>0){ + data.menu.SetSelection(Component(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{{96,4},{102,16}},"Online Characters",[](MenuFuncData data){ + Component(data.menu.GetType(),"Game Files List")->Disable(); + Component(data.menu.GetType(),"Online Game Files List")->Enable(); + Component(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(data.menu.GetType(),"Online Game Files List")->GetComponents().size()>0){ + data.menu.SetSelection(Component(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(type,"Online Game Files List")->GetComponents()[0]; + if(Component(type,"Online Game Files List")->GetComponents().size()>0){ + Menu::menus[type]->SetSelection(Component(type,"Online Game Files List")->GetComponents()[0],true); + returnData=Menu::menus[type]->GetSelection(); + }else{ + returnData="Go Back Button"; + } }else{ - returnData=Component(type,"Game Files List")->GetComponents()[0]; + if(Component(type,"Game Files List")->GetComponents().size()>0){ + Menu::menus[type]->SetSelection(Component(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(type,"Go Back Button")->Click(); }}}, + #ifdef __EMSCRIPTEN__ + {{game->KEY_FACELEFT},{[](MenuFuncData data){ + if(Component(data.menu.GetType(),"Offline Character Tab")->selected){ + return "Online Characters"; + }else{ + return "Offline Characters"; + } + },[](MenuType type){ + if(Component(type,"Offline Character Tab")->selected){ + Component(type,"Online Character Tab")->Click(); + }else{ + Component(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(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(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(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(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(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(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(type,"Game Files List")->GetComponents(); - if(gameFilesList.size()==0){ + std::vector>*gameFilesList=&Component(type,"Game Files List")->GetComponents(); + if(!Component(type,"Offline Character Tab")->selected){ + gameFilesList=&Component(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(type,"Game Files List")->GetComponents(); - if(gameFilesList.size()==0){ + std::vector>*gameFilesList=&Component(type,"Game Files List")->GetComponents(); + if(!Component(type,"Offline Character Tab")->selected){ + gameFilesList=&Component(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(type,"Offline Character Tab")->selected){ + Component(type,"Offline Character Tab")->Click(); + }else{ + Component(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(type,"Offline Character Tab")->selected){ + Component(type,"Offline Character Tab")->Click(); + }else{ + Component(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>*gameFilesList=&Component(type,"Game Files List")->GetComponents(); + if(!Component(type,"Offline Character Tab")->selected){ + gameFilesList=&Component(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(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(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>*gameFilesList=&Component(type,"Game Files List")->GetComponents(); + if(!Component(type,"Offline Character Tab")->selected){ + gameFilesList=&Component(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(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(type,"Offline Character Tab")->Click(); + if(Menu::menus[type]->GetSelection().expired()){ + returnData="Go Back Button"; + }else{ + returnData=Menu::menus[type]->GetSelection(); + } }, + #endif }}, }); #pragma endregion diff --git a/Adventures in Lestoria/MenuType.h b/Adventures in Lestoria/MenuType.h index 72ae9b07..a8a76006 100644 --- a/Adventures in Lestoria/MenuType.h +++ b/Adventures in Lestoria/MenuType.h @@ -41,7 +41,7 @@ enum MenuType{ /////////////////////////////////////////////////////////// /*DO NOT REMOVE!!*/ENUM_START,/////////////////////////////// /////////////////////////////////////////////////////////// - // 64% Controller Compatibility. (100 total items, 4 items per menu * 25 menus) + // 69% Controller Compatibility. (100 total items, 4 items per menu * 25 menus) INVENTORY_CONSUMABLES, //100% Controller Compatibility CLASS_INFO, //100% Controller Compatibility CLASS_SELECTION, //100% Controller Compatibility @@ -60,7 +60,7 @@ enum MenuType{ CRAFT_CONSUMABLE, //100% Controller Compatibility CONSUMABLE_CRAFT_ITEM, //100% Controller Compatibility SAVE_FILE_NAME, //100% Controller Compatibility - LOAD_GAME, //75% Controller Compatibility - Online Mode Tab switching + LOAD_GAME, //100% Controller Compatibility - Online Mode Tab switching USER_ID, //0% Controller Compatibility SETTINGS, //0% Controller Compatibility SHERMAN, //0% Controller Compatibility diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index fbc86b76..86a3d281 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 7299 +#define VERSION_BUILD 7300 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 08173ddf..881a095d 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ