|
|
@ -112,6 +112,23 @@ void Menu::InitializeMenus(){ |
|
|
|
if(menus.count(type)==0){ |
|
|
|
if(menus.count(type)==0){ |
|
|
|
ERR("WARNING! Menu Type "<<type<<" does not exist!") |
|
|
|
ERR("WARNING! Menu Type "<<type<<" does not exist!") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(menus[type]->defaultButton.expired()){ |
|
|
|
|
|
|
|
bool foundComponent=false; |
|
|
|
|
|
|
|
if(menus[type]->componentCount>0){ |
|
|
|
|
|
|
|
for(auto&[key,component]:menus[type]->components){ |
|
|
|
|
|
|
|
if(component->selectable){ |
|
|
|
|
|
|
|
menus[type]->defaultButton=component; |
|
|
|
|
|
|
|
std::cout<<std::format("WARNING! Menu {} does not have a default button! Automatically choosing {}",int(type),component->GetName())<<std::endl; |
|
|
|
|
|
|
|
foundComponent=true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!foundComponent){ |
|
|
|
|
|
|
|
std::cout<<std::format("WARNING! Menu {} does not have a default button and has no default components to set it automatically!",int(type))<<std::endl; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
for(auto&[key,value]:menus[type]->components){ |
|
|
|
for(auto&[key,value]:menus[type]->components){ |
|
|
|
value->AfterCreate(); |
|
|
|
value->AfterCreate(); |
|
|
|
} |
|
|
|
} |
|
|
@ -166,7 +183,7 @@ void Menu::Update(AiL*game){ |
|
|
|
HoverMenuSelect(game); |
|
|
|
HoverMenuSelect(game); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!UsingMouseNavigation()&&geom2d::line<float>(lastActiveMousePos,game->GetMousePos()).length()>="ThemeGlobal.MouseActivationDistance"_F||UsingMouseNavigation()){ |
|
|
|
if(!UsingMouseNavigation()&&geom2d::line<float>(lastActiveMousePos,game->GetMousePos()).length()>="ThemeGlobal.MouseActivationDistance"_F){ |
|
|
|
SetMouseNavigation(true); |
|
|
|
SetMouseNavigation(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -186,7 +203,6 @@ void Menu::Update(AiL*game){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
selection={}; |
|
|
|
|
|
|
|
for(auto&[key,component]:components){ |
|
|
|
for(auto&[key,component]:components){ |
|
|
|
if(component->selectable){ |
|
|
|
if(component->selectable){ |
|
|
|
if(!component->disabled&&!component->grayedOut){ |
|
|
|
if(!component->disabled&&!component->grayedOut){ |
|
|
@ -294,9 +310,14 @@ void Menu::Draw(AiL*game){ |
|
|
|
|
|
|
|
|
|
|
|
void Menu::OpenMenu(MenuType menu,bool cover){ |
|
|
|
void Menu::OpenMenu(MenuType menu,bool cover){ |
|
|
|
menus[menu]->cover=cover; |
|
|
|
menus[menu]->cover=cover; |
|
|
|
|
|
|
|
menus[menu]->selection=menus[menu]->defaultButton; |
|
|
|
stack.push_back(menus[menu]); |
|
|
|
stack.push_back(menus[menu]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Menu::SetDefaultButton(std::weak_ptr<MenuComponent>button){ |
|
|
|
|
|
|
|
defaultButton=button; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){ |
|
|
|
void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){ |
|
|
|
std::weak_ptr<MenuComponent>prevSelection=selection; |
|
|
|
std::weak_ptr<MenuComponent>prevSelection=selection; |
|
|
|
|
|
|
|
|
|
|
@ -420,7 +441,6 @@ bool Menu::UsingMouseNavigation(){ |
|
|
|
void Menu::SetMouseNavigation(bool mouseNavigation){ |
|
|
|
void Menu::SetMouseNavigation(bool mouseNavigation){ |
|
|
|
if(MOUSE_NAVIGATION&&!mouseNavigation){ |
|
|
|
if(MOUSE_NAVIGATION&&!mouseNavigation){ |
|
|
|
//When mouse navigation was enabled and now needs to be disabled, we store the mouse position.
|
|
|
|
//When mouse navigation was enabled and now needs to be disabled, we store the mouse position.
|
|
|
|
INCLUDE_game |
|
|
|
|
|
|
|
lastActiveMousePos=game->GetMousePos(); |
|
|
|
lastActiveMousePos=game->GetMousePos(); |
|
|
|
} |
|
|
|
} |
|
|
|
MOUSE_NAVIGATION=mouseNavigation; |
|
|
|
MOUSE_NAVIGATION=mouseNavigation; |
|
|
|