The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'! https://forums.lestoria.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AdventuresInLestoria/Crawler/TestSubMenu.cpp

66 lines
1.9 KiB

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