diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index c2c2cae4..b37b22d4 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -2548,12 +2548,6 @@ const MapName&AiL::GetCurrentMapName()const{ } void AiL::ValidateGameStatus(){ - if(IToggleable::uninitializedToggleGroupItems.size()>0){ - for(std::weak_ptritem:IToggleable::uninitializedToggleGroupItems){ - std::cout<<"\tUninitialized Toggle Item Ptr: 0x"<ADD("Weapon Inventory Display",RowInventoryScrollableWindowComponent)(geom2d::rect{{2,28},{220,blacksmithWindow->size.y-44}},"Item Name Label","Item Description Label", [](MenuFuncData data){ - std::weak_ptrcomp=DYNAMIC_POINTER_CAST(data.component.lock()); + std::weak_ptrcomp=dynamic_pointer_cast(data.component.lock()); const std::weak_ptritem=comp.lock()->GetItem(); std::string label=""; @@ -109,7 +109,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){ return true; }, [](MenuFuncData data){ - std::weak_ptrrowItem=DYNAMIC_POINTER_CAST(data.component.lock()); + std::weak_ptrrowItem=dynamic_pointer_cast(data.component.lock()); Component(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{{2,28},{220,blacksmithWindow->size.y-44}},"Item Name Label","Item Description Label", [](MenuFuncData data){ Menu::OpenMenu(CRAFT_ITEM); - std::weak_ptrcomp=DYNAMIC_POINTER_CAST(data.component.lock()); + std::weak_ptrcomp=dynamic_pointer_cast(data.component.lock()); const std::weak_ptritem=comp.lock()->GetItem(); std::string label=""; @@ -143,7 +143,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){ return true; }, [](MenuFuncData data){ - std::weak_ptrrowItem=DYNAMIC_POINTER_CAST(data.component.lock()); + std::weak_ptrrowItem=dynamic_pointer_cast(data.component.lock()); Component(BLACKSMITH,"Item Icon")->SetItem(rowItem.lock()->GetItem()); return true; }, diff --git a/Adventures in Lestoria/CharacterMenuWindow.cpp b/Adventures in Lestoria/CharacterMenuWindow.cpp index 56ba231e..bff16a87 100644 --- a/Adventures in Lestoria/CharacterMenuWindow.cpp +++ b/Adventures in Lestoria/CharacterMenuWindow.cpp @@ -145,13 +145,13 @@ void Menu::InitializeCharacterMenuWindow(){ auto equip=equipList->ADD("Equip Item "+std::to_string(counter),RowItemDisplay)(geom2d::rect{{2,2+counter*29.f},{120-15,28}},it, [](MenuFuncData data){ - std::weak_ptrcomp=DYNAMIC_POINTER_CAST(data.component.lock()); + std::weak_ptrcomp=dynamic_pointer_cast(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_ptrbutton:DYNAMIC_POINTER_CAST(data.parentComponent.lock())->GetComponents()){ - std::weak_ptrcomp=DYNAMIC_POINTER_CAST(button.lock()); + for(std::weak_ptrbutton:dynamic_pointer_cast(data.parentComponent.lock())->GetComponents()){ + std::weak_ptrcomp=dynamic_pointer_cast(button.lock()); comp.lock()->SetSelected(false); } comp.lock()->SetSelected(true); @@ -170,7 +170,7 @@ void Menu::InitializeCharacterMenuWindow(){ equip->SetHoverFunc( [&](MenuFuncData data){ - std::weak_ptrbutton=DYNAMIC_POINTER_CAST(data.component.lock()); + std::weak_ptrbutton=dynamic_pointer_cast(data.component.lock()); if(!button.expired()){ const std::weak_ptrbuttonItem=button.lock()->GetItem(); std::vectorstatsBeforeEquip; @@ -237,7 +237,7 @@ void Menu::InitializeCharacterMenuWindow(){ equipmentWindowOpened=true; return true; },[](MenuFuncData data){//On Mouse Hover - EquipSlot slot=DYNAMIC_POINTER_CAST(data.component.lock())->GetSlot(); + EquipSlot slot=dynamic_pointer_cast(data.component.lock())->GetSlot(); const std::weak_ptrequip=Inventory::GetEquip(slot); if(!ISBLANK(equip)){ Component(data.component.lock()->parentMenu,"Character Rotating Display")->Enable(false); diff --git a/Adventures in Lestoria/ConsumableCraftingWindow.cpp b/Adventures in Lestoria/ConsumableCraftingWindow.cpp index a224ce6a..42dd7b97 100644 --- a/Adventures in Lestoria/ConsumableCraftingWindow.cpp +++ b/Adventures in Lestoria/ConsumableCraftingWindow.cpp @@ -55,7 +55,7 @@ void Menu::InitializeConsumableCraftingWindow(){ #pragma region Craftables Inventory Display auto craftingItemsDisplay=consumableCraftingWindow->ADD("Crafting Inventory Display",RowInventoryScrollableWindowComponent)(geom2d::rect{{2,28},{220,consumableCraftingWindow->size.y-44}},"Item Name Label","Item Description Label", [](MenuFuncData data){ - std::weak_ptrcomp=DYNAMIC_POINTER_CAST(data.component.lock()); + std::weak_ptrcomp=dynamic_pointer_cast(data.component.lock()); const std::weak_ptritem=comp.lock()->GetItem(); Component(CONSUMABLE_CRAFT_ITEM,"Item Name Header")->GetString(A::ITEM_NAME)=item.lock()->ActualName(); Component(CONSUMABLE_CRAFT_ITEM,"Amount to Craft Amount Label")->SetLabel("1"); @@ -68,7 +68,7 @@ void Menu::InitializeConsumableCraftingWindow(){ return true; }, [](MenuFuncData data){ - std::weak_ptrrowItem=DYNAMIC_POINTER_CAST(data.component.lock()); + std::weak_ptrrowItem=dynamic_pointer_cast(data.component.lock()); if(rowItem.lock()->GetItem().lock()->GetEnhancementInfo().AvailableChapter()<=game->GetCurrentChapter()){ Component(CRAFT_CONSUMABLE,"Item Icon")->SetHideDetails(false); }else{ diff --git a/Adventures in Lestoria/Error.h b/Adventures in Lestoria/Error.h index f795ce65..ed44228c 100644 --- a/Adventures in Lestoria/Error.h +++ b/Adventures in Lestoria/Error.h @@ -85,9 +85,10 @@ type DYNAMIC_CAST(auto variable){ return pointer; } +/* template std::shared_ptrDYNAMIC_POINTER_CAST(auto variable){ std::shared_ptrpointer=std::dynamic_pointer_cast(variable); if(pointer)ERR("Could not dynamic cast to type "<ADD("inventory",InventoryScrollableWindowComponent)(geom2d::rect{{0,15},{windowSize.x,96.f}},"itemName","itemDescription", [&](MenuFuncData data){ - std::weak_ptrbutton=DYNAMIC_POINTER_CAST(data.component.lock()); + std::weak_ptrbutton=dynamic_pointer_cast(data.component.lock()); data.game->ClearLoadoutItem(data.menu.I(A::LOADOUT_SLOT)); for(std::weak_ptrcomponent: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_ptrbutton2=DYNAMIC_POINTER_CAST(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_ptrbutton2=dynamic_pointer_cast(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){ diff --git a/Adventures in Lestoria/InventoryScrollableWindowComponent.h b/Adventures in Lestoria/InventoryScrollableWindowComponent.h index 2b82d84d..81a10e00 100644 --- a/Adventures in Lestoria/InventoryScrollableWindowComponent.h +++ b/Adventures in Lestoria/InventoryScrollableWindowComponent.h @@ -94,7 +94,7 @@ public: virtual inline void SetCompactDescriptions(CompactText compact){ this->compact=compact; for(std::weak_ptrcomponent:components){ - std::weak_ptritemButton=DYNAMIC_POINTER_CAST(component.lock()); + std::weak_ptritemButton=dynamic_pointer_cast(component.lock()); itemButton.lock()->SetCompactDescriptions(compact); } } diff --git a/Adventures in Lestoria/InventoryWindow.cpp b/Adventures in Lestoria/InventoryWindow.cpp index 621b26ff..a61656df 100644 --- a/Adventures in Lestoria/InventoryWindow.cpp +++ b/Adventures in Lestoria/InventoryWindow.cpp @@ -90,7 +90,7 @@ void Menu::InitializeInventoryWindow(){ auto inventoryDisplay=inventoryWindow->ADD("Inventory Display - "+category,RowInventoryScrollableWindowComponent)(geom2d::rect{{72,28},{150,inventoryWindow->size.y-44}},"Item Name Label","Item Description Label",DO_NOTHING, [](MenuFuncData data){ - Component(data.menu.GetType(),"Item Icon")->SetItem(DYNAMIC_POINTER_CAST(data.component.lock())->GetItem()); + Component(data.menu.GetType(),"Item Icon")->SetItem(dynamic_pointer_cast(data.component.lock())->GetItem()); return true; }, [](MenuFuncData data){ diff --git a/Adventures in Lestoria/Menu.cpp b/Adventures in Lestoria/Menu.cpp index bfc14d02..e72db057 100644 --- a/Adventures in Lestoria/Menu.cpp +++ b/Adventures in Lestoria/Menu.cpp @@ -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(selection.lock()->parentComponent.lock())}); + bool buttonStillValid=selection.lock()->onClick(MenuFuncData{*this,game,selection,dynamic_pointer_cast(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>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_ptrc1,std::weak_ptrc2){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_ptrscrollableComponent=DYNAMIC_POINTER_CAST(selection.lock()->parentComponent.lock()); + std::weak_ptrscrollableComponent=dynamic_pointer_cast(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_ptrcomponent:inventoryListeners.at(cat)){ - std::weak_ptrcomp=DYNAMIC_POINTER_CAST(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_ptrcomp=dynamic_pointer_cast(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_ptrcomponent:merchantInventoryListeners.at(cat)){ - std::weak_ptrcomp=DYNAMIC_POINTER_CAST(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_ptrcomp=dynamic_pointer_cast(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_ptrcomponent,ITCategory category){ if(inventoryListeners.count(category)){ std::vector>&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 "<name<<" has already been added to the "<component,ITCategory category){ if(merchantInventoryListeners.count(category)){ std::vector>&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 "<name<<" has already been added to the "<component,IT } void Menu::AddEquipStatListener(std::weak_ptrcomponent){ - 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 "<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_ptrcomponent){ - 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 "<name<<" has already been added to the Chapter listener list! There should not be any duplicates!!") } chapterListeners.push_back(component); diff --git a/Adventures in Lestoria/Menu.h b/Adventures in Lestoria/Menu.h index 90282157..dbd5acd6 100644 --- a/Adventures in Lestoria/Menu.h +++ b/Adventures in Lestoria/Menu.h @@ -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< std::shared_ptrComponent(MenuType menu,std::string componentName){ - return DYNAMIC_POINTER_CAST(Menu::menus[menu]->components[componentName]); + return dynamic_pointer_cast(Menu::menus[menu]->components[componentName]); } struct MenuFuncData{ diff --git a/Adventures in Lestoria/MenuAnimatedIconToggleButton.h b/Adventures in Lestoria/MenuAnimatedIconToggleButton.h index 17b46f27..2f12d7f0 100644 --- a/Adventures in Lestoria/MenuAnimatedIconToggleButton.h +++ b/Adventures in Lestoria/MenuAnimatedIconToggleButton.h @@ -51,7 +51,7 @@ private: public: inline MenuAnimatedIconToggleButton(geom2d::rectrect,std::string animation,MenuFunc onClick) :MenuAnimatedIconButton(rect,animation,[](MenuFuncData data){ - std::weak_ptrbutton=DYNAMIC_POINTER_CAST(data.component.lock()); + std::weak_ptrbutton=dynamic_pointer_cast(data.component.lock()); button.lock()->Select(); button.lock()->_onClick(data); return true; diff --git a/Adventures in Lestoria/MenuComponent.cpp b/Adventures in Lestoria/MenuComponent.cpp index a739edbc..9798d496 100644 --- a/Adventures in Lestoria/MenuComponent.cpp +++ b/Adventures in Lestoria/MenuComponent.cpp @@ -211,7 +211,7 @@ void MenuComponent::_OnMouseOut(){ if(runHoverFunctions){ if(hoverState){ hoverState=false; - onMouseOut(MenuFuncData{*Menu::menus[parentMenu],game,std::make_shared(*this),DYNAMIC_POINTER_CAST(parentComponent.lock())}); + //onMouseOut(MenuFuncData{*Menu::menus[parentMenu],game,std::make_shared(*this),dynamic_pointer_cast(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(*this),DYNAMIC_POINTER_CAST(parentComponent.lock())}); + //onHover(MenuFuncData{*Menu::menus[parentMenu],game,std::make_shared(*this),dynamic_pointer_cast(parentComponent.lock())}); OnHover(); } } diff --git a/Adventures in Lestoria/MerchantWindow.cpp b/Adventures in Lestoria/MerchantWindow.cpp index fcfccd4e..fa032f61 100644 --- a/Adventures in Lestoria/MerchantWindow.cpp +++ b/Adventures in Lestoria/MerchantWindow.cpp @@ -94,7 +94,7 @@ void Menu::InitializeMerchantWindow(){ auto inventoryDisplay=merchantWindow->ADD("Merchant Inventory Display",RowInventoryScrollableWindowComponent)(geom2d::rect{{2,28},{220,merchantWindow->size.y-44}},"Item Name Label","Item Description Label", [](MenuFuncData data){ - std::weak_ptritem=DYNAMIC_POINTER_CAST(data.component.lock()); + std::weak_ptritem=dynamic_pointer_cast(data.component.lock()); Component(BUY_ITEM,"Item Purchase Header")->S(A::ITEM_NAME)=item.lock()->GetItem().lock()->ActualName(); Component(BUY_ITEM,"Price per item Amount Label")->SetLabel(std::to_string(item.lock()->GetItem().lock()->BuyValue())); Component(BUY_ITEM,"Amount to buy Amount Label")->SetLabel("1"); @@ -111,7 +111,7 @@ void Menu::InitializeMerchantWindow(){ return true; }, [](MenuFuncData data){ - Component(data.menu.GetType(),"Item Icon")->SetItem(DYNAMIC_POINTER_CAST(data.component.lock())->GetItem()); + Component(data.menu.GetType(),"Item Icon")->SetItem(dynamic_pointer_cast(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{{72,28},{150,merchantWindow->size.y-44}},"Item Name Label","Item Description Label", [](MenuFuncData data){ - std::weak_ptritem=DYNAMIC_POINTER_CAST(data.component.lock()); + std::weak_ptritem=dynamic_pointer_cast(data.component.lock()); if(item.lock()->GetItem().lock()->CanBeSold()){ Component(SELL_ITEM,"Item Sell Header")->SetItem(item.lock()->GetItem()); Component(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(data.menu.GetType(),"Item Icon")->SetItem(DYNAMIC_POINTER_CAST(data.component.lock())->GetItem()); + Component(data.menu.GetType(),"Item Icon")->SetItem(dynamic_pointer_cast(data.component.lock())->GetItem()); return true; }, [](MenuFuncData data){ diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index 04d0dd51..b14fdcbb 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -1069,7 +1069,7 @@ void Player::SetMoney(uint32_t newMoney){ } } void Player::AddMoneyListener(std::weak_ptrcomponent){ - 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 "<GetName()<<" has already been added to the Chapter listener list! There should not be any duplicates!!") } moneyListeners.push_back(component); diff --git a/Adventures in Lestoria/RowInventoryScrollableWindowComponent.h b/Adventures in Lestoria/RowInventoryScrollableWindowComponent.h index ced09e09..5f5fb6bf 100644 --- a/Adventures in Lestoria/RowInventoryScrollableWindowComponent.h +++ b/Adventures in Lestoria/RowInventoryScrollableWindowComponent.h @@ -52,7 +52,7 @@ public: virtual inline void SetCompactDescriptions(CompactText compact)override final{ this->compact=compact; for(std::weak_ptrcomponent:components){ - std::weak_ptritemButton=DYNAMIC_POINTER_CAST(component.lock()); + std::weak_ptritemButton=dynamic_pointer_cast(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_ptrcomponent:components){ - std::weak_ptritemButton=DYNAMIC_POINTER_CAST(component.lock()); + std::weak_ptritemButton=dynamic_pointer_cast(component.lock()); itemButton.lock()->SetPriceLabelType(labelType); } } diff --git a/Adventures in Lestoria/SaveFile.cpp b/Adventures in Lestoria/SaveFile.cpp index bb0be149..e0b4aed5 100644 --- a/Adventures in Lestoria/SaveFile.cpp +++ b/Adventures in Lestoria/SaveFile.cpp @@ -224,7 +224,7 @@ const void SaveFile::UpdateSaveGameData(){ for(size_t i=0;iADD(std::format("Load File Button - Save {}",i),LoadFileButton)(geom2d::rect{{0,offsetY},{gameFilesList->GetSize().x-13,48}},metadata[std::format("save{}",i)],i,[](MenuFuncData data){ - std::weak_ptrcomp=DYNAMIC_POINTER_CAST(data.component.lock()); + std::weak_ptrcomp=dynamic_pointer_cast(data.component.lock()); saveFileID=comp.lock()->getSaveFileID(); SaveFile::LoadGame(); return true; diff --git a/Adventures in Lestoria/ScrollableWindowComponent.h b/Adventures in Lestoria/ScrollableWindowComponent.h index 3306597d..72252c14 100644 --- a/Adventures in Lestoria/ScrollableWindowComponent.h +++ b/Adventures in Lestoria/ScrollableWindowComponent.h @@ -43,7 +43,7 @@ All rights reserved. using A=Attribute; -class ScrollableWindowComponent:public MenuComponent,std::enable_shared_from_this{ +class ScrollableWindowComponent:public MenuComponent{ protected: ViewPort subWindow; std::vector>components; @@ -71,7 +71,7 @@ public: } } virtual inline void RemoveButton(std::weak_ptrbutton){ - auto componentSearchResults=std::find(components.begin(),components.end(),[&](const std::weak_ptr&ptr){return &*ptr.lock()==&*button.lock();}); + auto componentSearchResults=std::find_if(components.begin(),components.end(),[&](const std::weak_ptr&ptr){return ptr.lock()==button.lock();}); if(componentSearchResults==components.end())ERR("Could not find Component"<GetName())<<" inside the component list!"); components.erase(componentSearchResults); Menu::menus[button.lock()->parentMenu]->RecalculateComponentCount(); @@ -218,7 +218,7 @@ public: std::shared_ptr _AddComponent(std::string key,std::shared_ptrbutton){ 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(); diff --git a/Adventures in Lestoria/Toggleable.h b/Adventures in Lestoria/Toggleable.h index 3aefdcbe..172263ac 100644 --- a/Adventures in Lestoria/Toggleable.h +++ b/Adventures in Lestoria/Toggleable.h @@ -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_ptritem){return this==&*item.lock();}); } inline void SetToggleGroup(std::vector>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"<>toggleGroup; private: bool selected=false; bool toggleGroupInitialized=false; - inline static std::vector>uninitializedToggleGroupItems; }; \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index caedf674..e4027efa 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -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