[BUG] Current build does not properly start and has two stub functions MenuComponent.cpp lines 214 and 224

This commit is contained in:
sigonasr2 2024-01-16 00:53:29 -06:00
parent c0ae0697b7
commit e669968bc3
19 changed files with 43 additions and 57 deletions

View File

@ -2548,12 +2548,6 @@ const MapName&AiL::GetCurrentMapName()const{
}
void AiL::ValidateGameStatus(){
if(IToggleable::uninitializedToggleGroupItems.size()>0){
for(std::weak_ptr<IToggleable>item:IToggleable::uninitializedToggleGroupItems){
std::cout<<"\tUninitialized Toggle Item Ptr: 0x"<<std::hex<<item.lock()<<std::endl;
}
ERR("Error TOGGLE!!! Please turn on debug_toggleable_items in configuration.txt and re-run the program to see which toggleable item did not properly get a toggleable group set.");
}
if(Unlock::unlocks.size()==0){
ERR("WARNING! There are no unlocks set! This was probably not intentional! It means no areasa on the overworld are accessible!");
}

View File

@ -93,7 +93,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){
#pragma region Weapon Inventory Display
auto weaponsDisplay=blacksmithWindow->ADD("Weapon Inventory Display",RowInventoryScrollableWindowComponent)(geom2d::rect<float>{{2,28},{220,blacksmithWindow->size.y-44}},"Item Name Label","Item Description Label",
[](MenuFuncData data){
std::weak_ptr<RowItemDisplay>comp=DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock());
std::weak_ptr<RowItemDisplay>comp=dynamic_pointer_cast<RowItemDisplay>(data.component.lock());
const std::weak_ptr<Item>item=comp.lock()->GetItem();
std::string label="";
@ -109,7 +109,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){
return true;
},
[](MenuFuncData data){
std::weak_ptr<RowItemDisplay>rowItem=DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock());
std::weak_ptr<RowItemDisplay>rowItem=dynamic_pointer_cast<RowItemDisplay>(data.component.lock());
Component<MenuItemItemButton>(BLACKSMITH,"Item Icon")->SetItem(rowItem.lock()->GetItem());
return true;
},
@ -128,7 +128,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){
auto armorDisplay=blacksmithWindow->ADD("Armor Inventory Display",RowInventoryScrollableWindowComponent)(geom2d::rect<float>{{2,28},{220,blacksmithWindow->size.y-44}},"Item Name Label","Item Description Label",
[](MenuFuncData data){
Menu::OpenMenu(CRAFT_ITEM);
std::weak_ptr<RowItemDisplay>comp=DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock());
std::weak_ptr<RowItemDisplay>comp=dynamic_pointer_cast<RowItemDisplay>(data.component.lock());
const std::weak_ptr<Item>item=comp.lock()->GetItem();
std::string label="";
@ -143,7 +143,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){
return true;
},
[](MenuFuncData data){
std::weak_ptr<RowItemDisplay>rowItem=DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock());
std::weak_ptr<RowItemDisplay>rowItem=dynamic_pointer_cast<RowItemDisplay>(data.component.lock());
Component<MenuItemItemButton>(BLACKSMITH,"Item Icon")->SetItem(rowItem.lock()->GetItem());
return true;
},

View File

@ -145,13 +145,13 @@ void Menu::InitializeCharacterMenuWindow(){
auto equip=equipList->ADD("Equip Item "+std::to_string(counter),RowItemDisplay)(geom2d::rect<float>{{2,2+counter*29.f},{120-15,28}},it,
[](MenuFuncData data){
std::weak_ptr<RowItemDisplay>comp=DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock());
std::weak_ptr<RowItemDisplay>comp=dynamic_pointer_cast<RowItemDisplay>(data.component.lock());
if(!comp.expired()){
if(OppositeRingSlotDoesNotMatchCurrentEquip(comp.lock())){ //If we find that the opposite ring slot is equipped to us, this would be an item swap or the exact same ring, therefore no stat calculations apply.
Inventory::EquipItem(comp.lock()->GetItem(),EquipSlot(comp.lock()->I(Attribute::EQUIP_TYPE)));
SoundEffect::PlaySFX(comp.lock()->GetItem().lock()->UseSound(),SoundEffect::CENTERED);
for(std::weak_ptr<MenuComponent>button:DYNAMIC_POINTER_CAST<ScrollableWindowComponent>(data.parentComponent.lock())->GetComponents()){
std::weak_ptr<RowItemDisplay>comp=DYNAMIC_POINTER_CAST<RowItemDisplay>(button.lock());
for(std::weak_ptr<MenuComponent>button:dynamic_pointer_cast<ScrollableWindowComponent>(data.parentComponent.lock())->GetComponents()){
std::weak_ptr<RowItemDisplay>comp=dynamic_pointer_cast<RowItemDisplay>(button.lock());
comp.lock()->SetSelected(false);
}
comp.lock()->SetSelected(true);
@ -170,7 +170,7 @@ void Menu::InitializeCharacterMenuWindow(){
equip->SetHoverFunc(
[&](MenuFuncData data){
std::weak_ptr<RowItemDisplay>button=DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock());
std::weak_ptr<RowItemDisplay>button=dynamic_pointer_cast<RowItemDisplay>(data.component.lock());
if(!button.expired()){
const std::weak_ptr<Item>buttonItem=button.lock()->GetItem();
std::vector<float>statsBeforeEquip;
@ -237,7 +237,7 @@ void Menu::InitializeCharacterMenuWindow(){
equipmentWindowOpened=true;
return true;
},[](MenuFuncData data){//On Mouse Hover
EquipSlot slot=DYNAMIC_POINTER_CAST<EquipSlotButton>(data.component.lock())->GetSlot();
EquipSlot slot=dynamic_pointer_cast<EquipSlotButton>(data.component.lock())->GetSlot();
const std::weak_ptr<Item>equip=Inventory::GetEquip(slot);
if(!ISBLANK(equip)){
Component<CharacterRotatingDisplay>(data.component.lock()->parentMenu,"Character Rotating Display")->Enable(false);

View File

@ -55,7 +55,7 @@ void Menu::InitializeConsumableCraftingWindow(){
#pragma region Craftables Inventory Display
auto craftingItemsDisplay=consumableCraftingWindow->ADD("Crafting Inventory Display",RowInventoryScrollableWindowComponent)(geom2d::rect<float>{{2,28},{220,consumableCraftingWindow->size.y-44}},"Item Name Label","Item Description Label",
[](MenuFuncData data){
std::weak_ptr<RowItemDisplay>comp=DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock());
std::weak_ptr<RowItemDisplay>comp=dynamic_pointer_cast<RowItemDisplay>(data.component.lock());
const std::weak_ptr<Item>item=comp.lock()->GetItem();
Component<MenuLabel>(CONSUMABLE_CRAFT_ITEM,"Item Name Header")->GetString(A::ITEM_NAME)=item.lock()->ActualName();
Component<MenuLabel>(CONSUMABLE_CRAFT_ITEM,"Amount to Craft Amount Label")->SetLabel("1");
@ -68,7 +68,7 @@ void Menu::InitializeConsumableCraftingWindow(){
return true;
},
[](MenuFuncData data){
std::weak_ptr<RowItemDisplay>rowItem=DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock());
std::weak_ptr<RowItemDisplay>rowItem=dynamic_pointer_cast<RowItemDisplay>(data.component.lock());
if(rowItem.lock()->GetItem().lock()->GetEnhancementInfo().AvailableChapter()<=game->GetCurrentChapter()){
Component<MenuItemItemButton>(CRAFT_CONSUMABLE,"Item Icon")->SetHideDetails(false);
}else{

View File

@ -85,9 +85,10 @@ type DYNAMIC_CAST(auto variable){
return pointer;
}
/*
template<typename type>
std::shared_ptr<type>DYNAMIC_POINTER_CAST(auto variable){
std::shared_ptr<type>pointer=std::dynamic_pointer_cast<type>(variable);
if(pointer)ERR("Could not dynamic cast to type "<<typeid(variable).name()<<"!");
return pointer;
}
}*/

View File

@ -56,11 +56,11 @@ void Menu::InitializeConsumableInventoryWindow(){
auto consumableWindow=inventoryWindow->ADD("inventory",InventoryScrollableWindowComponent)(geom2d::rect<float>{{0,15},{windowSize.x,96.f}},"itemName","itemDescription",
[&](MenuFuncData data){
std::weak_ptr<MenuItemButton>button=DYNAMIC_POINTER_CAST<MenuItemButton>(data.component.lock());
std::weak_ptr<MenuItemButton>button=dynamic_pointer_cast<MenuItemButton>(data.component.lock());
data.game->ClearLoadoutItem(data.menu.I(A::LOADOUT_SLOT));
for(std::weak_ptr<MenuComponent>component:data.parentComponent.lock()->GetComponents()){ //HACK ALERT! If we are accessing a parent component, it's because we are dealing with a scrolling window component, which has sub-components. So this should be a safe cast to make.
if(component.lock()->GetName().starts_with("item")){
std::weak_ptr<MenuItemButton>button2=DYNAMIC_POINTER_CAST<MenuItemButton>(component.lock());//HACK ALERT! This is probably an item since we populated item lists using this name for the components. So we assume these are MenuItemButton classes.
std::weak_ptr<MenuItemButton>button2=dynamic_pointer_cast<MenuItemButton>(component.lock());//HACK ALERT! This is probably an item since we populated item lists using this name for the components. So we assume these are MenuItemButton classes.
if(button2.expired())ERR("Could not cast item to a MenuItemButton*!");
if(&*button2.lock()==&*button.lock()){
if(button2.lock()->selected!=-1){

View File

@ -94,7 +94,7 @@ public:
virtual inline void SetCompactDescriptions(CompactText compact){
this->compact=compact;
for(std::weak_ptr<MenuComponent>component:components){
std::weak_ptr<MenuItemButton>itemButton=DYNAMIC_POINTER_CAST<MenuItemButton>(component.lock());
std::weak_ptr<MenuItemButton>itemButton=dynamic_pointer_cast<MenuItemButton>(component.lock());
itemButton.lock()->SetCompactDescriptions(compact);
}
}

View File

@ -90,7 +90,7 @@ void Menu::InitializeInventoryWindow(){
auto inventoryDisplay=inventoryWindow->ADD("Inventory Display - "+category,RowInventoryScrollableWindowComponent)(geom2d::rect<float>{{72,28},{150,inventoryWindow->size.y-44}},"Item Name Label","Item Description Label",DO_NOTHING,
[](MenuFuncData data){
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->SetItem(DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock())->GetItem());
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->SetItem(dynamic_pointer_cast<RowItemDisplay>(data.component.lock())->GetItem());
return true;
},
[](MenuFuncData data){

View File

@ -149,7 +149,7 @@ void Menu::HoverMenuSelect(AiL*game){
void Menu::MenuSelect(AiL*game){
if(!game->IsFocused()||selection.expired()||(selection.lock()->disabled||selection.lock()->grayedOut))return;
bool buttonStillValid=selection.lock()->onClick(MenuFuncData{*this,game,selection,DYNAMIC_POINTER_CAST<ScrollableWindowComponent>(selection.lock()->parentComponent.lock())});
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){
if(stack.size()<32){
@ -255,7 +255,7 @@ void Menu::Draw(AiL*game){
std::vector<std::weak_ptr<MenuComponent>>allComponents;
std::for_each(components.begin(),components.end(),[&](auto&pair){allComponents.push_back(pair.second);});
std::sort(allComponents.begin(),allComponents.end(),[](MenuComponent*c1,MenuComponent*c2){return c1->depth>c2->depth;});
std::sort(allComponents.begin(),allComponents.end(),[](std::weak_ptr<MenuComponent>c1,std::weak_ptr<MenuComponent>c2){return c1.lock()->depth>c2.lock()->depth;});
if(GetCurrentTheme().IsScaled()){
DrawScaledWindowBorder(game,pos,size,GetRenderColor());
@ -275,7 +275,7 @@ void Menu::Draw(AiL*game){
vf2d drawOffset{};
if(!selection.expired()){
if(!selection.lock()->parentComponent.expired()){
std::weak_ptr<ScrollableWindowComponent>scrollableComponent=DYNAMIC_POINTER_CAST<ScrollableWindowComponent>(selection.lock()->parentComponent.lock());
std::weak_ptr<ScrollableWindowComponent>scrollableComponent=dynamic_pointer_cast<ScrollableWindowComponent>(selection.lock()->parentComponent.lock());
drawOffset+=scrollableComponent.lock()->GetScrollAmount();
}
draggingComponent->V(A::DRAW_OFFSET)=drawOffset+pos-offsetPos+selection.lock()->rect.pos+vi2d{1,-4};
@ -425,7 +425,7 @@ void Menu::SetMouseNavigation(bool mouseNavigation){
void Menu::InventorySlotsUpdated(ITCategory cat){
//Update the inventory with a new inventory slot, since there's one additional item to interact with now.
for(std::weak_ptr<MenuComponent>component:inventoryListeners.at(cat)){
std::weak_ptr<InventoryScrollableWindowComponent>comp=DYNAMIC_POINTER_CAST<InventoryScrollableWindowComponent>(component.lock()); //HACK ALERT! We're assuming that these must be these classes otherwise they have no reason to even be using these listeners. Make sure that the lowest base class that requires these implements these functions!!!
std::weak_ptr<InventoryScrollableWindowComponent>comp=dynamic_pointer_cast<InventoryScrollableWindowComponent>(component.lock()); //HACK ALERT! We're assuming that these must be these classes otherwise they have no reason to even be using these listeners. Make sure that the lowest base class that requires these implements these functions!!!
comp.lock()->OnInventorySlotsUpdate(cat);
}
}
@ -433,7 +433,7 @@ void Menu::InventorySlotsUpdated(ITCategory cat){
void Menu::MerchantInventorySlotsUpdated(ITCategory cat){
//Update the inventory with a new inventory slot, since there's one additional item to interact with now.
for(std::weak_ptr<MenuComponent>component:merchantInventoryListeners.at(cat)){
std::weak_ptr<InventoryScrollableWindowComponent>comp=DYNAMIC_POINTER_CAST<InventoryScrollableWindowComponent>(component.lock()); //HACK ALERT! We're assuming that these must be these classes otherwise they have no reason to even be using these listeners. Make sure that the lowest base class that requires these implements these functions!!!
std::weak_ptr<InventoryScrollableWindowComponent>comp=dynamic_pointer_cast<InventoryScrollableWindowComponent>(component.lock()); //HACK ALERT! We're assuming that these must be these classes otherwise they have no reason to even be using these listeners. Make sure that the lowest base class that requires these implements these functions!!!
comp.lock()->OnInventorySlotsUpdate(cat);
}
}
@ -441,7 +441,7 @@ void Menu::MerchantInventorySlotsUpdated(ITCategory cat){
void Menu::AddInventoryListener(std::weak_ptr<MenuComponent>component,ITCategory category){
if(inventoryListeners.count(category)){
std::vector<std::weak_ptr<MenuComponent>>&listenerList=inventoryListeners.at(category);
if(std::find(listenerList.begin(),listenerList.end(),[&](auto&ptr){return &*ptr.lock()==&*component.lock();})!=listenerList.end()){
if(std::find_if(listenerList.begin(),listenerList.end(),[&](auto&ptr){return &*ptr.lock()==&*component.lock();})!=listenerList.end()){
ERR("WARNING! Component "<<component.lock()->name<<" has already been added to the "<<category<<" listener list! There should not be any duplicates!!")
}
listenerList.push_back(component);
@ -458,7 +458,7 @@ void Menu::InitializeMenuListenerCategory(const std::string&category){
void Menu::AddMerchantInventoryListener(std::weak_ptr<MenuComponent>component,ITCategory category){
if(merchantInventoryListeners.count(category)){
std::vector<std::weak_ptr<MenuComponent>>&listenerList=merchantInventoryListeners.at(category);
if(std::find(listenerList.begin(),listenerList.end(),[&](auto&ptr){return &*ptr.lock()==&*component.lock();})!=listenerList.end()){
if(std::find_if(listenerList.begin(),listenerList.end(),[&](auto&ptr){return &*ptr.lock()==&*component.lock();})!=listenerList.end()){
ERR("WARNING! Component "<<component.lock()->name<<" has already been added to the "<<category<<" merchant listener list! There should not be any duplicates!!")
}
listenerList.push_back(component);
@ -468,7 +468,7 @@ void Menu::AddMerchantInventoryListener(std::weak_ptr<MenuComponent>component,IT
}
void Menu::AddEquipStatListener(std::weak_ptr<MenuComponent>component){
if(std::find(equipStatListeners.begin(),equipStatListeners.end(),[&](auto&ptr){return &*ptr.lock()==&*component.lock();})!=equipStatListeners.end()){
if(std::find_if(equipStatListeners.begin(),equipStatListeners.end(),[&](auto&ptr){return &*ptr.lock()==&*component.lock();})!=equipStatListeners.end()){
ERR("WARNING! Component "<<component.lock()->name<<" has already been added to the Equip Stat listener list! There should not be any duplicates!!")
}
equipStatListeners.push_back(component);
@ -542,7 +542,7 @@ void Menu::LockInListeners(){
}
void Menu::AddChapterListener(std::weak_ptr<MenuComponent>component){
if(std::find(chapterListeners.begin(),chapterListeners.end(),[&](auto&ptr){return &*ptr.lock()==&*component.lock();})!=chapterListeners.end()){
if(std::find_if(chapterListeners.begin(),chapterListeners.end(),[&](auto&ptr){return &*ptr.lock()==&*component.lock();})!=chapterListeners.end()){
ERR("WARNING! Component "<<component.lock()->name<<" has already been added to the Chapter listener list! There should not be any duplicates!!")
}
chapterListeners.push_back(component);

View File

@ -142,6 +142,7 @@ public:
component->name=componentKey;
components.Unlock(); //It's possible we can add a component later on, so we will make sure we remove the lock first.
components[componentKey]=component;
std::cout<<componentKey<<" Created!"<<std::endl;
components.SetInitialized();
lastRegisteredComponent=componentKey;
@ -214,7 +215,7 @@ private:
template<typename T>
std::shared_ptr<T>Component(MenuType menu,std::string componentName){
return DYNAMIC_POINTER_CAST<T>(Menu::menus[menu]->components[componentName]);
return dynamic_pointer_cast<T>(Menu::menus[menu]->components[componentName]);
}
struct MenuFuncData{

View File

@ -51,7 +51,7 @@ private:
public:
inline MenuAnimatedIconToggleButton(geom2d::rect<float>rect,std::string animation,MenuFunc onClick)
:MenuAnimatedIconButton(rect,animation,[](MenuFuncData data){
std::weak_ptr<MenuAnimatedIconToggleButton>button=DYNAMIC_POINTER_CAST<MenuAnimatedIconToggleButton>(data.component.lock());
std::weak_ptr<MenuAnimatedIconToggleButton>button=dynamic_pointer_cast<MenuAnimatedIconToggleButton>(data.component.lock());
button.lock()->Select();
button.lock()->_onClick(data);
return true;

View File

@ -211,7 +211,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();
}
}
@ -221,7 +221,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();
}
}

View File

@ -94,7 +94,7 @@ void Menu::InitializeMerchantWindow(){
auto inventoryDisplay=merchantWindow->ADD("Merchant Inventory Display",RowInventoryScrollableWindowComponent)(geom2d::rect<float>{{2,28},{220,merchantWindow->size.y-44}},"Item Name Label","Item Description Label",
[](MenuFuncData data){
std::weak_ptr<RowItemDisplay>item=DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock());
std::weak_ptr<RowItemDisplay>item=dynamic_pointer_cast<RowItemDisplay>(data.component.lock());
Component<MenuLabel>(BUY_ITEM,"Item Purchase Header")->S(A::ITEM_NAME)=item.lock()->GetItem().lock()->ActualName();
Component<MenuLabel>(BUY_ITEM,"Price per item Amount Label")->SetLabel(std::to_string(item.lock()->GetItem().lock()->BuyValue()));
Component<MenuLabel>(BUY_ITEM,"Amount to buy Amount Label")->SetLabel("1");
@ -111,7 +111,7 @@ void Menu::InitializeMerchantWindow(){
return true;
},
[](MenuFuncData data){
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->SetItem(DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock())->GetItem());
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->SetItem(dynamic_pointer_cast<RowItemDisplay>(data.component.lock())->GetItem());
return true;
},
[](MenuFuncData data){
@ -152,7 +152,7 @@ void Menu::InitializeMerchantWindow(){
auto inventoryDisplay=merchantWindow->ADD("Inventory Display - "+category,RowInventoryScrollableWindowComponent)(geom2d::rect<float>{{72,28},{150,merchantWindow->size.y-44}},"Item Name Label","Item Description Label",
[](MenuFuncData data){
std::weak_ptr<RowItemDisplay>item=DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock());
std::weak_ptr<RowItemDisplay>item=dynamic_pointer_cast<RowItemDisplay>(data.component.lock());
if(item.lock()->GetItem().lock()->CanBeSold()){
Component<ItemMenuLabel>(SELL_ITEM,"Item Sell Header")->SetItem(item.lock()->GetItem());
Component<MenuLabel>(SELL_ITEM,"Price per item Amount Label")->SetLabel(std::to_string(item.lock()->GetItem().lock()->SellValue()));
@ -171,7 +171,7 @@ void Menu::InitializeMerchantWindow(){
return true;
},
[](MenuFuncData data){
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->SetItem(DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock())->GetItem());
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->SetItem(dynamic_pointer_cast<RowItemDisplay>(data.component.lock())->GetItem());
return true;
},
[](MenuFuncData data){

View File

@ -1069,7 +1069,7 @@ void Player::SetMoney(uint32_t newMoney){
}
}
void Player::AddMoneyListener(std::weak_ptr<MenuComponent>component){
if(std::find(moneyListeners.begin(),moneyListeners.end(),[&](auto&ptr){return &*ptr.lock()==&*component.lock();})!=moneyListeners.end()){
if(std::find_if(moneyListeners.begin(),moneyListeners.end(),[&](auto&ptr){return &*ptr.lock()==&*component.lock();})!=moneyListeners.end()){
ERR("WARNING! Component "<<component.lock()->GetName()<<" has already been added to the Chapter listener list! There should not be any duplicates!!")
}
moneyListeners.push_back(component);

View File

@ -52,7 +52,7 @@ public:
virtual inline void SetCompactDescriptions(CompactText compact)override final{
this->compact=compact;
for(std::weak_ptr<MenuComponent>component:components){
std::weak_ptr<RowItemDisplay>itemButton=DYNAMIC_POINTER_CAST<RowItemDisplay>(component.lock());
std::weak_ptr<RowItemDisplay>itemButton=dynamic_pointer_cast<RowItemDisplay>(component.lock());
itemButton.lock()->SetCompactDescriptions(compact);
}
}
@ -60,7 +60,7 @@ public:
virtual inline void SetPriceLabelType(PriceLabel::PriceLabel labelType)final{
this->priceLabel=labelType;
for(std::weak_ptr<MenuComponent>component:components){
std::weak_ptr<RowItemDisplay>itemButton=DYNAMIC_POINTER_CAST<RowItemDisplay>(component.lock());
std::weak_ptr<RowItemDisplay>itemButton=dynamic_pointer_cast<RowItemDisplay>(component.lock());
itemButton.lock()->SetPriceLabelType(labelType);
}
}

View File

@ -224,7 +224,7 @@ const void SaveFile::UpdateSaveGameData(){
for(size_t i=0;i<saveFileCount;i++){
if(metadata.HasProperty(std::format("save{}",i))){
gameFilesList->ADD(std::format("Load File Button - Save {}",i),LoadFileButton)(geom2d::rect<float>{{0,offsetY},{gameFilesList->GetSize().x-13,48}},metadata[std::format("save{}",i)],i,[](MenuFuncData data){
std::weak_ptr<LoadFileButton>comp=DYNAMIC_POINTER_CAST<LoadFileButton>(data.component.lock());
std::weak_ptr<LoadFileButton>comp=dynamic_pointer_cast<LoadFileButton>(data.component.lock());
saveFileID=comp.lock()->getSaveFileID();
SaveFile::LoadGame();
return true;

View File

@ -43,7 +43,7 @@ All rights reserved.
using A=Attribute;
class ScrollableWindowComponent:public MenuComponent,std::enable_shared_from_this<ScrollableWindowComponent>{
class ScrollableWindowComponent:public MenuComponent{
protected:
ViewPort subWindow;
std::vector<std::weak_ptr<MenuComponent>>components;
@ -71,7 +71,7 @@ public:
}
}
virtual inline void RemoveButton(std::weak_ptr<MenuComponent>button){
auto componentSearchResults=std::find(components.begin(),components.end(),[&](const std::weak_ptr<MenuComponent>&ptr){return &*ptr.lock()==&*button.lock();});
auto componentSearchResults=std::find_if(components.begin(),components.end(),[&](const std::weak_ptr<MenuComponent>&ptr){return ptr.lock()==button.lock();});
if(componentSearchResults==components.end())ERR("Could not find Component"<<std::quoted(button.lock()->GetName())<<" inside the component list!");
components.erase(componentSearchResults);
Menu::menus[button.lock()->parentMenu]->RecalculateComponentCount();
@ -218,7 +218,7 @@ public:
std::shared_ptr<T> _AddComponent(std::string key,std::shared_ptr<T>button){
components.push_back(button);
button->renderInMain=false; //Now we are in control!
button->parentComponent=shared_from_this();
button->parentComponent=Menu::menus[parentMenu]->components[this->GetName()];
button->disabled=disabled;
CalculateBounds();

View File

@ -57,24 +57,14 @@ public:
ERR("WARNING! Toggle group for this component was set twice for some reason! THIS SHOULD NOT BE HAPPENING!")
}
toggleGroupInitialized=true;
std::erase_if(uninitializedToggleGroupItems,[&](std::weak_ptr<IToggleable>item){return this==&*item.lock();});
}
inline void SetToggleGroup(std::vector<std::weak_ptr<IToggleable>>toggleGroup){
this->toggleGroup=toggleGroup;
SetToggleGroup();
}
inline IToggleable(){
uninitializedToggleGroupItems.push_back(shared_from_this());
#ifdef _DEBUG
if("debug_toggleable_items"_I){
std::cout<<"\tInitialized Toggle Item Ptr: 0x"<<std::hex<<this<<std::endl;
}
#endif
}
protected:
std::vector<std::weak_ptr<IToggleable>>toggleGroup;
private:
bool selected=false;
bool toggleGroupInitialized=false;
inline static std::vector<std::weak_ptr<IToggleable>>uninitializedToggleGroupItems;
};

View File

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