Fix more dynamic pointer strict casts to parent components (when they shouldn't be). Fixed double updating bug for components in ScrollableWindowComponents.

pull/35/head
sigonasr2 11 months ago
parent 848d0e4816
commit bc1a1c6876
  1. 8
      Adventures in Lestoria/Menu.cpp
  2. 4
      Adventures in Lestoria/MenuComponent.cpp
  3. 4
      Adventures in Lestoria/ScrollableWindowComponent.h
  4. 2
      Adventures in Lestoria/Version.h

@ -239,10 +239,14 @@ void Menu::Update(AiL*game){
}
for(auto&[key,component]:components){
component->_BeforeUpdate(game);
if(component->renderInMain){
component->_BeforeUpdate(game);
}
}
for(auto&[key,component]:components){
component->_Update(game);
if(component->renderInMain){
component->_Update(game);
}
}
};

@ -212,7 +212,7 @@ void MenuComponent::_OnMouseOut(){
if(runHoverFunctions){
if(hoverState){
hoverState=false;
onMouseOut(MenuFuncData{*Menu::menus[parentMenu],game,std::make_shared<MenuComponent>(*this),DYNAMIC_POINTER_CAST<ScrollableWindowComponent>(parentComponent.lock())});
onMouseOut(MenuFuncData{*Menu::menus[parentMenu],game,std::make_shared<MenuComponent>(*this),dynamic_pointer_cast<ScrollableWindowComponent>(parentComponent.lock())});
OnMouseOut();
}
}
@ -222,7 +222,7 @@ void MenuComponent::_OnHover(){
if(hovered){
if(runHoverFunctions&&!hoverState){
hoverState=true;
onHover(MenuFuncData{*Menu::menus[parentMenu],game,std::make_shared<MenuComponent>(*this),DYNAMIC_POINTER_CAST<ScrollableWindowComponent>(parentComponent.lock())});
onHover(MenuFuncData{*Menu::menus[parentMenu],game,std::make_shared<MenuComponent>(*this),dynamic_pointer_cast<ScrollableWindowComponent>(parentComponent.lock())});
OnHover();
}
}

@ -106,7 +106,9 @@ protected:
virtual inline void BeforeUpdate(AiL*game)override{
MenuComponent::BeforeUpdate(game);
for(std::weak_ptr<MenuComponent>component:components){
component.lock()->_BeforeUpdate(game);
std::shared_ptr<MenuComponent>componentPtr=component.lock();
if(componentPtr->renderInMain)ERR(std::format("WARNING! Component {} is inside a ScrollableWindowComponent but renders in main instead! Parent Component: {}",componentPtr->GetName(),GetName()));
componentPtr->_BeforeUpdate(game);
}
}
virtual inline void Update(AiL*game)override{

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 1
#define VERSION_BUILD 5947
#define VERSION_BUILD 5950
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save