diff --git a/Crawler/ClassSelectionWindow.cpp b/Crawler/ClassSelectionWindow.cpp index 12e15896..dbf65b53 100644 --- a/Crawler/ClassSelectionWindow.cpp +++ b/Crawler/ClassSelectionWindow.cpp @@ -4,6 +4,7 @@ #include "Menu.h" #include "MenuLabel.h" #include "MenuAnimatedIconButton.h" +#include "GameState.h" INCLUDE_game typedef Attribute A; @@ -22,6 +23,13 @@ void Menu::InitializeClassSelectionWindow(){ classSelectionWindow->AddComponent("Outline Border",outline); + vf2d navigationButtonSize={24*2.5f,16}; + + MenuComponent*backButton=new MenuComponent(CLASS_SELECTION,{{4+2,outlineSize.y+4-navigationButtonSize.y-2},navigationButtonSize},"Back",[](MenuFuncData data){Menu::CloseMenu();}); + classSelectionWindow->AddComponent("Back Button",backButton); + MenuComponent*confirmButton=new MenuComponent(CLASS_SELECTION,{{outlineSize.x+4-navigationButtonSize.x-2,outlineSize.y+4-navigationButtonSize.y-2},navigationButtonSize},"Confirm",[](MenuFuncData data){GameState::ChangeState(States::GAME_RUN);}); + classSelectionWindow->AddComponent("Confirm",confirmButton); + vf2d buttonPadding={2,2}; vf2d buttonSize={floor(outlineSize.y/3-buttonPadding.y*3),outlineSize.y/9-buttonPadding.y*3}; //The floor is for fixing a small pixel rounding bug. diff --git a/Crawler/Menu.cpp b/Crawler/Menu.cpp index f9ca84b2..1ebcf0e7 100644 --- a/Crawler/Menu.cpp +++ b/Crawler/Menu.cpp @@ -156,7 +156,7 @@ void Menu::HoverMenuSelect(Crawler*game){ void Menu::MenuSelect(Crawler*game){ if(selection==vi2d{-1,-1}||buttons[selection.y][selection.x]->disabled)return; - buttons[selection.y][selection.x]->onClick(MenuFuncData{*this,game,buttons[selection.y][selection.x]}); + buttons[selection.y][selection.x]->onClick(MenuFuncData{*this,game,buttons[selection.y][selection.x]}); if(buttons[selection.y][selection.x]->menuDest!=MenuType::ENUM_END){ if(stack.size()<32){ stack.push_back(menus[buttons[selection.y][selection.x]->menuDest]);//Navigate to the next menu. @@ -639,4 +639,12 @@ void Menu::CloseMenu(){ std::pairMenu::GetMemoryLeakReportInfo(){ return {lastMenuTypeCreated,lastRegisteredComponent}; +} + +void Menu::CloseAllMenus(){ + if(stack.size()<=0){ + std::cout<<"WARNING! Trying to close out no menu?? Why are we doing this?"<stack; static std::string themeSelection; static safeunorderedmapthemes; diff --git a/Crawler/State_GameRun.cpp b/Crawler/State_GameRun.cpp index da4f253f..6adc680c 100644 --- a/Crawler/State_GameRun.cpp +++ b/Crawler/State_GameRun.cpp @@ -7,7 +7,7 @@ INCLUDE_MONSTER_LIST void State_GameRun::OnStateChange(GameState*prevState){ - Menu::stack.clear(); + Menu::CloseAllMenus(); }; void State_GameRun::OnUserUpdate(Crawler*game){ game->bossDisplayTimer=std::max(0.f,game->bossDisplayTimer-game->GetElapsedTime()); diff --git a/Crawler/Version.h b/Crawler/Version.h index 56b0df1b..894c36a3 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 2391 +#define VERSION_BUILD 2393 #define stringify(a) stringify_(a) #define stringify_(a) #a