#include "Crawler.h" #include "Menu.h" #include "DEFINES.h" #include "olcPixelGameEngine.h" #include "safemap.h" #include "MenuIconButton.h" #include "MenuLabel.h" INCLUDE_GFX typedef Attribute A; const Menu Menu::InitializeTestSubMenu(){ Menu testSubMenu({30,30},{24*4,24*5}); MenuFunc goBack=[](Menu&menu,Crawler*game){ menu.stack.pop_back(); }; testSubMenu.AddComponent("BACK",new MenuComponent({{24*1,24*1},{24*2,24*1}},"Go Back",goBack)); int index=0; for(auto&theme:Menu::themes){ if(theme.displayName==Menu::themeSelection){ testSubMenu.I(A::INDEXED_THEME)=index; break; } index++; } MenuFunc themePrev=[](Menu&menu,Crawler*game){ bool found=false; menu.I(A::INDEXED_THEME)--; if(menu.I(A::INDEXED_THEME)<0){ menu.I(A::INDEXED_THEME)=themes.size()-1; } int index=0; for(auto&theme:Menu::themes){ if(index==menu.I(A::INDEXED_THEME)){ Menu::themeSelection=theme.displayName; ((MenuLabel*)(menu.components["THEME_DISPLAY"]))->SetLabel("Theme\n"+Menu::themes[themeSelection].GetThemeName()); break; } index++; } }; testSubMenu.AddComponent("PREV_THEME",new MenuComponent({{24*-0.5,24*3},{24*1,24*1}},"<",themePrev)); testSubMenu.AddComponent("THEME_DISPLAY",new MenuLabel({{24*0.5,24*3},{24*3,24*1}},"Theme\n"+Menu::themes[themeSelection].GetThemeName())); MenuFunc themeNext=[](Menu&menu,Crawler*game){ menu.I(A::INDEXED_THEME)=(size_t(menu.I(A::INDEXED_THEME))+1)%themes.size(); int index=0; for(auto&theme:Menu::themes){ if(index==menu.I(A::INDEXED_THEME)){ Menu::themeSelection=theme.displayName; ((MenuLabel*)(menu.components["THEME_DISPLAY"]))->SetLabel("Theme\n"+Menu::themes[themeSelection].GetThemeName()); break; } index++; } }; testSubMenu.AddComponent("NEXT_THEME",new MenuComponent({{24*3.5,24*3},{24*1,24*1}},">",themeNext)); return testSubMenu; }