Added XP bar animations and steady increasing progress bar. Added level up animation text on stage completion screen. Refactor enable and disable functions for menu components. Differentiated between disabling due to being outside the window, and manual enable/disabling of components. Fix infinite loop bug with components outside of a scrollable window component not being iterated over. Fix bug with hovering over non-navigational components causing the default component for a menu to be selected while in mouse navigation mode. Release Build 7095.
This commit is contained in:
@@ -132,7 +132,7 @@ void Menu::CheckClickAndPerformMenuSelect(AiL*game){
|
||||
}
|
||||
|
||||
void Menu::HoverMenuSelect(AiL*game){
|
||||
if(!game->IsFocused()||selection.expired()||selection.lock()->disabled||selection.lock()->grayedOut||Menu::alreadyClicked||Menu::scrolling)return;
|
||||
if(!game->IsFocused()||selection.expired()||selection.lock()->disable||selection.lock()->disableOutsideWindow||selection.lock()->grayedOut||Menu::alreadyClicked||Menu::scrolling)return;
|
||||
|
||||
if(selection.lock()->draggable){
|
||||
if(buttonHoldTime<"ThemeGlobal.MenuHoldTime"_F){
|
||||
@@ -147,7 +147,7 @@ void Menu::HoverMenuSelect(AiL*game){
|
||||
}
|
||||
|
||||
void Menu::MenuSelect(AiL*game){
|
||||
if(!game->IsFocused()||selection.expired()||selection.lock()->disabled||selection.lock()->grayedOut)return;
|
||||
if(!game->IsFocused()||selection.expired()||selection.lock()->disable||selection.lock()->disableOutsideWindow||selection.lock()->grayedOut)return;
|
||||
bool buttonStillValid=selection.lock()->onClick(MenuFuncData{*this,game,selection,dynamic_pointer_cast<ScrollableWindowComponent>(selection.lock()->parentComponent.lock())});
|
||||
if(buttonStillValid){
|
||||
if(selection.lock()->menuDest!=MenuType::ENUM_END){
|
||||
@@ -170,7 +170,7 @@ void Menu::Update(AiL*game){
|
||||
}
|
||||
|
||||
for(auto&[key,button]:components){
|
||||
if(!button->disabled){
|
||||
if(!button->disable||!button->disableOutsideWindow){
|
||||
button->hovered=false;
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ void Menu::Update(AiL*game){
|
||||
selection={};
|
||||
for(auto&[key,component]:components){
|
||||
if(component->selectable){
|
||||
if(!component->disabled&&!component->grayedOut){
|
||||
if(!component->disable&&!component->disableOutsideWindow&&!component->grayedOut){
|
||||
if(component->GetHoverState(game)){
|
||||
component->hovered=true;
|
||||
itemHovered=true;
|
||||
@@ -338,6 +338,8 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||
}
|
||||
}
|
||||
if(!selection.expired()){
|
||||
const int MAX_ITERATIONS=10; //Skip a maximum amount of items in case everything gets disabled somehow, prevents an infinite loop.
|
||||
int iterationCount=0;
|
||||
do{
|
||||
if(navigationGroups.size()==0)break; //We don't do anything here when there are no navigation groups.
|
||||
std::string selectionButtonName=selection.lock()->GetName();
|
||||
@@ -386,10 +388,15 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||
SetSelection(returnData);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
}else
|
||||
if(!Menu::UsingMouseNavigation()){
|
||||
if(std::holds_alternative<ButtonName>(defaultButton)&&std::get<ButtonName>(defaultButton).length()>0||std::holds_alternative<std::weak_ptr<MenuComponent>>(defaultButton))SetSelection(defaultButton,true);
|
||||
}else{
|
||||
break; //There's no reason to be doing anything here if we navigate with the mouse.
|
||||
}
|
||||
}while(selection.lock()->disabled||selection.lock()->grayedOut);
|
||||
iterationCount++;
|
||||
if(iterationCount==MAX_ITERATIONS)ERR("WARNING! We've entered the max iteration count of automatic Menu navigation! THIS LIKELY MEANS WE'VE DONE SOMETHING TERRIBLY WRONG!");
|
||||
}while(iterationCount<MAX_ITERATIONS&&(selection.lock()->grayedOut||selection.lock()->disable));
|
||||
}
|
||||
|
||||
if(game->KEY_UP.Released()||game->KEY_RIGHT.Released()||game->KEY_LEFT.Released()||game->KEY_DOWN.Released()||
|
||||
@@ -399,7 +406,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||
buttonHoldTime=0;
|
||||
}
|
||||
if(&*prevSelection.lock()!=&*selection.lock()){
|
||||
if(!selection.expired()&&(selection.lock()->disabled||selection.lock()->grayedOut)){
|
||||
if(!selection.expired()&&selection.lock()->disableOutsideWindow){
|
||||
bool handled=false;
|
||||
if(!UsingMouseNavigation()){
|
||||
//Let's transfer some information about our selection being off the screen. Our intention with keyboard controls is that the screen will scroll to the correct location instead.
|
||||
@@ -500,7 +507,7 @@ Pixel Menu::GetRenderColor(){
|
||||
}
|
||||
|
||||
bool Menu::HandleOutsideDisabledButtonSelection(std::weak_ptr<MenuComponent>disabledButton){
|
||||
if(!disabledButton.expired()){
|
||||
if(!disabledButton.expired()&&!disabledButton.lock()->parentComponent.expired()){
|
||||
return disabledButton.lock()->parentComponent.lock()->HandleOutsideDisabledButtonSelection(disabledButton);
|
||||
}else{
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user