diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 901e63e9..a2f80990 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -285,17 +285,6 @@ bool AiL::OnUserUpdate(float fElapsedTime){ RenderWorld(GetElapsedTime()); GameState::STATE->Draw(this); RenderMenu(); - if(Menu::stack.size()>0){ - std::weak_ptrcomponent=Menu::stack.back()->GetSelection(); - if(!component.expired()){ - DrawShadowStringDecal({2,2},"Selection: "+component.lock()->GetName()); - } - std::weak_ptrkeyComponent=Menu::stack.back()->GetKeySelection(); - if(!keyComponent.expired()){ - DrawShadowStringDecal({2,14},"Key Selection: "+keyComponent.lock()->GetName()); - } - } - DrawShadowStringDecal({2,26},"MOUSE NAVIGATION: "+std::to_string(Menu::MOUSE_NAVIGATION)); RenderFadeout(); RenderVersionInfo(); #ifndef __EMSCRIPTEN__ @@ -2484,6 +2473,24 @@ void AiL::RenderMenu(){ menu->Draw(this); } } + + #pragma region Menu Navigation Debug Info + #ifdef _DEBUG + if("debug_menu_navigation_info"_I){ + if(Menu::stack.size()>0){ + std::weak_ptrcomponent=Menu::stack.back()->GetSelection(); + if(!component.expired()){ + DrawShadowStringDecal({2,2},"Selection: "+component.lock()->GetName()); + } + std::weak_ptrkeyComponent=Menu::stack.back()->GetKeySelection(); + if(!keyComponent.expired()){ + DrawShadowStringDecal({2,14},"Key Selection: "+keyComponent.lock()->GetName()); + } + } + DrawShadowStringDecal({2,26},"MOUSE NAVIGATION: "+std::to_string(Menu::MOUSE_NAVIGATION)); + } + #endif + #pragma endregion } void AiL::InitializeGraphics(){ diff --git a/Adventures in Lestoria/ClassSelectionWindow.cpp b/Adventures in Lestoria/ClassSelectionWindow.cpp index 98ffd2d6..147ad248 100644 --- a/Adventures in Lestoria/ClassSelectionWindow.cpp +++ b/Adventures in Lestoria/ClassSelectionWindow.cpp @@ -59,8 +59,6 @@ void Menu::InitializeClassSelectionWindow(){ vf2d navigationButtonSize={24*2.5f,16}; - classSelectionWindow->ADD("Back Button",MenuComponent)(geom2d::rect{{4+2,outlineSize.y+4-navigationButtonSize.y-2},navigationButtonSize},"Back",[](MenuFuncData data){Menu::CloseMenu();return true;})END; - classSelectionWindow->ADD("Confirm",MenuComponent)(geom2d::rect{{outlineSize.x+4-navigationButtonSize.x-2,outlineSize.y+4-navigationButtonSize.y-2},navigationButtonSize},"Confirm",[](MenuFuncData data){ std::string selectedClass=data.component.lock()->S(A::CLASS_SELECTION); data.game->ChangePlayerClass(classutils::StringToClass(selectedClass)); diff --git a/Adventures in Lestoria/LoadGameWindow.cpp b/Adventures in Lestoria/LoadGameWindow.cpp index b62d0ddc..7c11e847 100644 --- a/Adventures in Lestoria/LoadGameWindow.cpp +++ b/Adventures in Lestoria/LoadGameWindow.cpp @@ -59,7 +59,7 @@ void Menu::InitializeLoadGameWindow(){ {game->KEY_START,{"Load File",[](MenuType type){ Menu::menus[type]->GetSelection().lock()->Click(); }}}, - {game->KEY_SELECT,{"Return to Title Screen",[](MenuType type){ + {game->KEY_BACK,{"Back to Title Screen",[](MenuType type){ Component(type,"Back Button")->Click(); }}}, } @@ -75,7 +75,35 @@ void Menu::InitializeLoadGameWindow(){ returnData=*(--component); } }, - .down="Go Back Button",}}, - {"Go Back Button",{}}, + .down=[](MenuType type,Data&returnData){ + auto&selection=Menu::menus[type]->GetSelection(); + auto&gameFilesList=Component(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(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(type,"Game Files List")->GetComponents(); + if(gameFilesList.size()==0){ + returnData="Go Back Button"; + return; + } + returnData=*(gameFilesList.begin()); + }, + }}, }); } \ No newline at end of file diff --git a/Adventures in Lestoria/Menu.cpp b/Adventures in Lestoria/Menu.cpp index 01499737..1f8ffa0c 100644 --- a/Adventures in Lestoria/Menu.cpp +++ b/Adventures in Lestoria/Menu.cpp @@ -295,9 +295,11 @@ void Menu::Draw(AiL*game){ void Menu::OpenMenu(MenuType menu,bool cover){ menus[menu]->cover=cover; - Data returnData; - menus[menu]->onOpenFunc(menu,returnData); - menus[menu]->SetSelection(returnData); + if(menus[menu]->onOpenFunc){ + Data returnData; + menus[menu]->onOpenFunc(menu,returnData); + menus[menu]->SetSelection(returnData); + } stack.push_back(menus[menu]); } diff --git a/Adventures in Lestoria/SaveFileWindow.cpp b/Adventures in Lestoria/SaveFileWindow.cpp index c2cedef4..8028cf0b 100644 --- a/Adventures in Lestoria/SaveFileWindow.cpp +++ b/Adventures in Lestoria/SaveFileWindow.cpp @@ -43,7 +43,9 @@ All rights reserved. void Menu::InitializeSaveFileWindow(){ Menu*saveFileWindow=CreateMenu(SAVE_FILE_NAME,CENTERED,vi2d{96,96}); saveFileWindow->ADD("Save File Name Entry Label",MenuLabel)(geom2d::rect{{-8,0},{112,36}},"Save File Name:",1.0f,ComponentAttr::SHADOW)END; - saveFileWindow->ADD("Save File Name Text Entry",TextEntryLabel)(geom2d::rect{{-8,36},{112,24}},TEXTCHANGE_DONOTHING,false,16U,2.f,ComponentAttr::FIT_TO_LABEL|ComponentAttr::OUTLINE|ComponentAttr::SHADOW|ComponentAttr::BACKGROUND)END; + saveFileWindow->ADD("Save File Name Text Entry",TextEntryLabel)(geom2d::rect{{-8,36},{112,24}},[](std::string_view updatedLabel){ + Component(SAVE_FILE_NAME,"Continue Button")->SetGrayedOut(updatedLabel.length()==0); + },false,16U,2.f,ComponentAttr::FIT_TO_LABEL|ComponentAttr::OUTLINE|ComponentAttr::SHADOW|ComponentAttr::BACKGROUND)END; saveFileWindow->ADD("Back Button",MenuComponent)(geom2d::rect{{-8,68},{48,12}},"Back",[](MenuFuncData data){Menu::CloseMenu();game->TextEntryEnable(false);return true;})END; saveFileWindow->ADD("Continue Button",MenuComponent)(geom2d::rect{{56,68},{48,12}},"Begin",MenuType::CLASS_SELECTION,[](MenuFuncData data){ SaveFile::SetSaveFileName(game->TextEntryGetString()); @@ -51,7 +53,8 @@ void Menu::InitializeSaveFileWindow(){ game->TextEntryEnable(false); SaveFile::SaveGame(); return true; - })END; + })END + ->SetGrayedOut(true); saveFileWindow->SetupKeyboardNavigation( diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 0abb80ca..ab404a2e 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 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 5997 +#define VERSION_BUILD 6004 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/config/configuration.txt b/Adventures in Lestoria/assets/config/configuration.txt index 03ef3822..720d434e 100644 --- a/Adventures in Lestoria/assets/config/configuration.txt +++ b/Adventures in Lestoria/assets/config/configuration.txt @@ -116,6 +116,9 @@ encrypted_font_size = Unknown,16 # Whether or not to show individual data accesses from config data structure. debug_access_options = 0 +# Shows menu navigation debug output +debug_menu_navigation_info = 0 + # Shows map loading output debug_map_load_info = 0