Resolved menu component bugs not being removed from parent menu structure properly.
This commit is contained in:
parent
965d0afdb1
commit
54f128777f
@ -139,15 +139,13 @@ std::function<void(InventoryScrollableWindowComponent&component,ITCategory cat)>
|
||||
#pragma region Row Player Weapons Updates
|
||||
std::function<void(InventoryScrollableWindowComponent&component,ITCategory cat)> InventoryCreator::RowPlayerWeapons_InventorySlotsUpdate=
|
||||
[](InventoryScrollableWindowComponent&component,ITCategory cat){
|
||||
std::vector<std::weak_ptr<Item>>weapons;
|
||||
std::copy_if(Inventory::get("Equipment").begin(),Inventory::get("Equipment").end(),std::back_inserter(weapons),[](std::weak_ptr<Item> item){return item.lock()->IsWeapon();});
|
||||
component.RemoveAllComponents();
|
||||
component.AddButtonOnSlotUpdate(cat);
|
||||
};
|
||||
std::function<void(InventoryScrollableWindowComponent&component,ITCategory cat)> InventoryCreator::RowPlayerWeapons_AddButtonOnSlotUpdate=
|
||||
[](InventoryScrollableWindowComponent&component,ITCategory cat){
|
||||
std::vector<std::weak_ptr<Item>>weapons;
|
||||
std::copy_if(Inventory::get("Equipment").begin(),Inventory::get("Equipment").end(),std::back_inserter(weapons),[](std::weak_ptr<Item> item){return item.lock()->IsWeapon();});
|
||||
std::copy_if(Inventory::get("Equipment").begin(),Inventory::get("Equipment").end(),std::back_inserter(weapons),[](std::shared_ptr<Item>item){return item->IsWeapon();});
|
||||
|
||||
RowInventoryScrollableWindowComponent*c=DYNAMIC_CAST<RowInventoryScrollableWindowComponent*>(&component);
|
||||
|
||||
@ -173,15 +171,13 @@ std::function<void(InventoryScrollableWindowComponent&component,ITCategory cat)>
|
||||
#pragma region Row Player Armor Updates
|
||||
std::function<void(InventoryScrollableWindowComponent&component,ITCategory cat)> InventoryCreator::RowPlayerArmor_InventorySlotsUpdate=
|
||||
[](InventoryScrollableWindowComponent&component,ITCategory cat){
|
||||
std::vector<std::weak_ptr<Item>>armor;
|
||||
std::copy_if(Inventory::get("Equipment").begin(),Inventory::get("Equipment").end(),std::back_inserter(armor),[](std::weak_ptr<Item> item){return item.lock()->IsArmor();});
|
||||
component.RemoveAllComponents();
|
||||
component.AddButtonOnSlotUpdate(cat);
|
||||
};
|
||||
std::function<void(InventoryScrollableWindowComponent&component,ITCategory cat)> InventoryCreator::RowPlayerArmor_AddButtonOnSlotUpdate=
|
||||
[](InventoryScrollableWindowComponent&component,ITCategory cat){
|
||||
std::vector<std::weak_ptr<Item>>armor;
|
||||
std::copy_if(Inventory::get("Equipment").begin(),Inventory::get("Equipment").end(),std::back_inserter(armor),[](std::weak_ptr<Item> item){return item.lock()->IsArmor();});
|
||||
std::copy_if(Inventory::get("Equipment").begin(),Inventory::get("Equipment").end(),std::back_inserter(armor),[](std::shared_ptr<Item>item){return item->IsArmor();});
|
||||
|
||||
RowInventoryScrollableWindowComponent*c=DYNAMIC_CAST<RowInventoryScrollableWindowComponent*>(&component);
|
||||
|
||||
|
||||
@ -142,7 +142,6 @@ 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;
|
||||
|
||||
|
||||
@ -74,7 +74,15 @@ public:
|
||||
auto componentSearchResults=std::find_if(components.begin(),components.end(),[&](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();
|
||||
size_t removedCount=0;
|
||||
|
||||
MenuType parentMenu=button.lock()->parentMenu;
|
||||
|
||||
removedCount+=Menu::menus[parentMenu]->components.erase(button.lock()->GetName());
|
||||
if(removedCount!=1){
|
||||
std::cout<<"WARNING! Attempted to remove buttons from button listing, but not found!";
|
||||
}
|
||||
Menu::menus[parentMenu]->RecalculateComponentCount();
|
||||
CalculateBounds();
|
||||
}
|
||||
virtual inline void SetScrollAmount(vf2d scrollOffset){
|
||||
|
||||
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 1
|
||||
#define VERSION_BUILD 5939
|
||||
#define VERSION_BUILD 5944
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user