|
|
@ -8,13 +8,15 @@ std::vector<Menu*>Menu::stack; |
|
|
|
std::map<MenuType,Menu>Menu::menus; |
|
|
|
std::map<MenuType,Menu>Menu::menus; |
|
|
|
std::string Menu::themeSelection="BlueDefault"; |
|
|
|
std::string Menu::themeSelection="BlueDefault"; |
|
|
|
safeunorderedmap<std::string,Theme>Menu::themes; |
|
|
|
safeunorderedmap<std::string,Theme>Menu::themes; |
|
|
|
|
|
|
|
const vf2d Menu::CENTERED = {-456,-456}; |
|
|
|
|
|
|
|
|
|
|
|
INCLUDE_GFX |
|
|
|
INCLUDE_GFX |
|
|
|
|
|
|
|
extern vi2d WINDOW_SIZE; |
|
|
|
|
|
|
|
|
|
|
|
Menu::Menu(){} |
|
|
|
Menu::Menu(){} |
|
|
|
|
|
|
|
|
|
|
|
Menu::Menu(vf2d size) |
|
|
|
Menu::Menu(vf2d pos,vf2d size) |
|
|
|
:size(size){} |
|
|
|
:pos(pos==CENTERED?WINDOW_SIZE/2-size/2:vi2d{pos}),size(size){} |
|
|
|
|
|
|
|
|
|
|
|
void Menu::InitializeMenus(){ |
|
|
|
void Menu::InitializeMenus(){ |
|
|
|
stack.reserve(32); |
|
|
|
stack.reserve(32); |
|
|
@ -57,7 +59,6 @@ void Menu::MenuSelect(Crawler*game){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Update(Crawler*game){ |
|
|
|
void Menu::Update(Crawler*game){ |
|
|
|
vf2d upperLeftPos=game->GetScreenSize()/2-size/2; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(auto&key:buttons){ |
|
|
|
for(auto&key:buttons){ |
|
|
|
for(auto&button:key.second){ |
|
|
|
for(auto&button:key.second){ |
|
|
@ -69,14 +70,14 @@ void Menu::Update(Crawler*game){ |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
for(auto&key:buttons){ |
|
|
|
for(auto&key:buttons){ |
|
|
|
for(auto&button:key.second){ |
|
|
|
for(auto&button:key.second){ |
|
|
|
if(geom2d::overlaps(geom2d::rect<float>{button->rect.pos+upperLeftPos,button->rect.size},game->GetMousePos())){ |
|
|
|
if(geom2d::overlaps(geom2d::rect<float>{button->rect.pos+pos,button->rect.size},game->GetMousePos())){ |
|
|
|
button->hovered=true; |
|
|
|
button->hovered=true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
KeyboardButtonNavigation(game,upperLeftPos); |
|
|
|
KeyboardButtonNavigation(game,pos); |
|
|
|
for(auto&key:buttons){ |
|
|
|
for(auto&key:buttons){ |
|
|
|
for(auto&button:key.second){ |
|
|
|
for(auto&button:key.second){ |
|
|
|
button->Update(game); |
|
|
|
button->Update(game); |
|
|
@ -88,21 +89,20 @@ void Menu::Update(Crawler*game){ |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Draw(Crawler*game){ |
|
|
|
void Menu::Draw(Crawler*game){ |
|
|
|
vf2d upperLeftPos=game->GetScreenSize()/2-size/2; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(GetCurrentTheme().IsScaled()){ |
|
|
|
if(GetCurrentTheme().IsScaled()){ |
|
|
|
DrawScaledWindow(game,upperLeftPos); |
|
|
|
DrawScaledWindow(game,pos); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
DrawTiledWindow(game,upperLeftPos); |
|
|
|
DrawTiledWindow(game,pos); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for(auto&key:buttons){ |
|
|
|
for(auto&key:buttons){ |
|
|
|
for(auto&button:key.second){ |
|
|
|
for(auto&button:key.second){ |
|
|
|
button->Draw(game,upperLeftPos,this==Menu::stack.back()); |
|
|
|
button->Draw(game,pos,this==Menu::stack.back()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for(auto&component:displayComponents){ |
|
|
|
for(auto&component:displayComponents){ |
|
|
|
component->Draw(game,upperLeftPos,this==Menu::stack.back()); |
|
|
|
component->Draw(game,pos,this==Menu::stack.back()); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|