Proper theming controls added, attributes are now an inheritable interface for anything.
This commit is contained in:
+21
-3
@@ -6,6 +6,8 @@
|
||||
bool Menu::MOUSE_NAVIGATION=true;
|
||||
std::vector<Menu*>Menu::stack;
|
||||
std::map<MenuType,Menu>Menu::menus;
|
||||
std::string Menu::themeSelection="9patch";
|
||||
safemap<std::string,Theme>Menu::themes;
|
||||
|
||||
INCLUDE_GFX
|
||||
|
||||
@@ -24,11 +26,21 @@ void Menu::InitializeMenus(){
|
||||
std::cout<<"WARNING! Menu Type "<<type<<" does not exist!"<<std::endl;
|
||||
throw;
|
||||
}
|
||||
menus[type].components.SetInitialized(); //Lock all known components to prevent invalid access.
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::AddComponent(MenuComponent*button){
|
||||
buttons[button->rect.pos.y].push_back(button);
|
||||
void Menu::AddComponent(std::string key,MenuComponent*button){
|
||||
if(button->selectable){
|
||||
buttons[button->rect.pos.y].push_back(button);
|
||||
}else{
|
||||
displayComponents.push_back(button);
|
||||
}
|
||||
if(components.count(key)){
|
||||
std::cout<<"WARNING! Key "<<key<<" for this sub-menu already exists! Key names must be unique!"<<std::endl;
|
||||
throw;
|
||||
}
|
||||
components[key]=button;
|
||||
}
|
||||
|
||||
void Menu::MenuSelect(Crawler*game){
|
||||
@@ -70,6 +82,9 @@ void Menu::Update(Crawler*game){
|
||||
button->Update(game);
|
||||
}
|
||||
}
|
||||
for(auto&component:displayComponents){
|
||||
component->Update(game);
|
||||
}
|
||||
};
|
||||
|
||||
void Menu::Draw(Crawler*game){
|
||||
@@ -86,6 +101,9 @@ void Menu::Draw(Crawler*game){
|
||||
button->Draw(game,upperLeftPos);
|
||||
}
|
||||
}
|
||||
for(auto&component:displayComponents){
|
||||
component->Draw(game,upperLeftPos);
|
||||
}
|
||||
};
|
||||
|
||||
void Menu::OpenMenu(MenuType menu){
|
||||
@@ -272,5 +290,5 @@ void Menu::DrawTiledWindow(Crawler*game,vf2d menuPos){
|
||||
}
|
||||
|
||||
Renderable&Menu::GetPatchPart(int x,int y){
|
||||
return GFX["9patch_"+std::to_string(x)+std::to_string(y)+".png"];
|
||||
return GFX[themeSelection+"_"+std::to_string(x)+std::to_string(y)+".png"];
|
||||
}
|
||||
Reference in New Issue
Block a user