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

pull/30/head
sigonasr2 11 months ago
parent c0ae0697b7
commit e669968bc3
  1. 6
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 8
      Adventures in Lestoria/BlacksmithCraftingWindow.cpp
  3. 10
      Adventures in Lestoria/CharacterMenuWindow.cpp
  4. 4
      Adventures in Lestoria/ConsumableCraftingWindow.cpp
  5. 3
      Adventures in Lestoria/Error.h
  6. 4
      Adventures in Lestoria/InventoryConsumableWindow.cpp
  7. 2
      Adventures in Lestoria/InventoryScrollableWindowComponent.h
  8. 2
      Adventures in Lestoria/InventoryWindow.cpp
  9. 18
      Adventures in Lestoria/Menu.cpp
  10. 3
      Adventures in Lestoria/Menu.h
  11. 2
      Adventures in Lestoria/MenuAnimatedIconToggleButton.h
  12. 4
      Adventures in Lestoria/MenuComponent.cpp
  13. 8
      Adventures in Lestoria/MerchantWindow.cpp
  14. 2
      Adventures in Lestoria/Player.cpp
  15. 4
      Adventures in Lestoria/RowInventoryScrollableWindowComponent.h
  16. 2
      Adventures in Lestoria/SaveFile.cpp
  17. 6
      Adventures in Lestoria/ScrollableWindowComponent.h
  18. 10
      Adventures in Lestoria/Toggleable.h
  19. 2
      Adventures in Lestoria/Version.h

@ -2548,12 +2548,6 @@ const MapName&AiL::GetCurrentMapName()const{
} }
void AiL::ValidateGameStatus(){ 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){ 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!"); ERR("WARNING! There are no unlocks set! This was probably not intentional! It means no areasa on the overworld are accessible!");
} }

@ -93,7 +93,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){
#pragma region Weapon Inventory Display #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", 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){ [](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(); const std::weak_ptr<Item>item=comp.lock()->GetItem();
std::string label=""; std::string label="";
@ -109,7 +109,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){
return true; return true;
}, },
[](MenuFuncData data){ [](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()); Component<MenuItemItemButton>(BLACKSMITH,"Item Icon")->SetItem(rowItem.lock()->GetItem());
return true; 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", 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){ [](MenuFuncData data){
Menu::OpenMenu(CRAFT_ITEM); 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(); const std::weak_ptr<Item>item=comp.lock()->GetItem();
std::string label=""; std::string label="";
@ -143,7 +143,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){
return true; return true;
}, },
[](MenuFuncData data){ [](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()); Component<MenuItemItemButton>(BLACKSMITH,"Item Icon")->SetItem(rowItem.lock()->GetItem());
return true; return true;
}, },

@ -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, 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){ [](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(!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. 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))); Inventory::EquipItem(comp.lock()->GetItem(),EquipSlot(comp.lock()->I(Attribute::EQUIP_TYPE)));
SoundEffect::PlaySFX(comp.lock()->GetItem().lock()->UseSound(),SoundEffect::CENTERED); SoundEffect::PlaySFX(comp.lock()->GetItem().lock()->UseSound(),SoundEffect::CENTERED);
for(std::weak_ptr<MenuComponent>button:DYNAMIC_POINTER_CAST<ScrollableWindowComponent>(data.parentComponent.lock())->GetComponents()){ 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()); std::weak_ptr<RowItemDisplay>comp=dynamic_pointer_cast<RowItemDisplay>(button.lock());
comp.lock()->SetSelected(false); comp.lock()->SetSelected(false);
} }
comp.lock()->SetSelected(true); comp.lock()->SetSelected(true);
@ -170,7 +170,7 @@ void Menu::InitializeCharacterMenuWindow(){
equip->SetHoverFunc( equip->SetHoverFunc(
[&](MenuFuncData data){ [&](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()){ if(!button.expired()){
const std::weak_ptr<Item>buttonItem=button.lock()->GetItem(); const std::weak_ptr<Item>buttonItem=button.lock()->GetItem();
std::vector<float>statsBeforeEquip; std::vector<float>statsBeforeEquip;
@ -237,7 +237,7 @@ void Menu::InitializeCharacterMenuWindow(){
equipmentWindowOpened=true; equipmentWindowOpened=true;
return true; return true;
},[](MenuFuncData data){//On Mouse Hover },[](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); const std::weak_ptr<Item>equip=Inventory::GetEquip(slot);
if(!ISBLANK(equip)){ if(!ISBLANK(equip)){
Component<CharacterRotatingDisplay>(data.component.lock()->parentMenu,"Character Rotating Display")->Enable(false); Component<CharacterRotatingDisplay>(data.component.lock()->parentMenu,"Character Rotating Display")->Enable(false);

@ -55,7 +55,7 @@ void Menu::InitializeConsumableCraftingWindow(){
#pragma region Craftables Inventory Display #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", 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){ [](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(); 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,"Item Name Header")->GetString(A::ITEM_NAME)=item.lock()->ActualName();
Component<MenuLabel>(CONSUMABLE_CRAFT_ITEM,"Amount to Craft Amount Label")->SetLabel("1"); Component<MenuLabel>(CONSUMABLE_CRAFT_ITEM,"Amount to Craft Amount Label")->SetLabel("1");
@ -68,7 +68,7 @@ void Menu::InitializeConsumableCraftingWindow(){
return true; return true;
}, },
[](MenuFuncData data){ [](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()){ if(rowItem.lock()->GetItem().lock()->GetEnhancementInfo().AvailableChapter()<=game->GetCurrentChapter()){
Component<MenuItemItemButton>(CRAFT_CONSUMABLE,"Item Icon")->SetHideDetails(false); Component<MenuItemItemButton>(CRAFT_CONSUMABLE,"Item Icon")->SetHideDetails(false);
}else{ }else{

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

@ -56,11 +56,11 @@ void Menu::InitializeConsumableInventoryWindow(){
auto consumableWindow=inventoryWindow->ADD("inventory",InventoryScrollableWindowComponent)(geom2d::rect<float>{{0,15},{windowSize.x,96.f}},"itemName","itemDescription", auto consumableWindow=inventoryWindow->ADD("inventory",InventoryScrollableWindowComponent)(geom2d::rect<float>{{0,15},{windowSize.x,96.f}},"itemName","itemDescription",
[&](MenuFuncData data){ [&](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)); 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. 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")){ 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.expired())ERR("Could not cast item to a MenuItemButton*!");
if(&*button2.lock()==&*button.lock()){ if(&*button2.lock()==&*button.lock()){
if(button2.lock()->selected!=-1){ if(button2.lock()->selected!=-1){

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

@ -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, 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){ [](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; return true;
}, },
[](MenuFuncData data){ [](MenuFuncData data){

@ -149,7 +149,7 @@ void Menu::HoverMenuSelect(AiL*game){
void Menu::MenuSelect(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()->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(buttonStillValid){
if(selection.lock()->menuDest!=MenuType::ENUM_END){ if(selection.lock()->menuDest!=MenuType::ENUM_END){
if(stack.size()<32){ if(stack.size()<32){
@ -255,7 +255,7 @@ void Menu::Draw(AiL*game){
std::vector<std::weak_ptr<MenuComponent>>allComponents; std::vector<std::weak_ptr<MenuComponent>>allComponents;
std::for_each(components.begin(),components.end(),[&](auto&pair){allComponents.push_back(pair.second);}); 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()){ if(GetCurrentTheme().IsScaled()){
DrawScaledWindowBorder(game,pos,size,GetRenderColor()); DrawScaledWindowBorder(game,pos,size,GetRenderColor());
@ -275,7 +275,7 @@ void Menu::Draw(AiL*game){
vf2d drawOffset{}; vf2d drawOffset{};
if(!selection.expired()){ if(!selection.expired()){
if(!selection.lock()->parentComponent.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(); drawOffset+=scrollableComponent.lock()->GetScrollAmount();
} }
draggingComponent->V(A::DRAW_OFFSET)=drawOffset+pos-offsetPos+selection.lock()->rect.pos+vi2d{1,-4}; 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){ void Menu::InventorySlotsUpdated(ITCategory cat){
//Update the inventory with a new inventory slot, since there's one additional item to interact with now. //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)){ 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); comp.lock()->OnInventorySlotsUpdate(cat);
} }
} }
@ -433,7 +433,7 @@ void Menu::InventorySlotsUpdated(ITCategory cat){
void Menu::MerchantInventorySlotsUpdated(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. //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)){ 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); comp.lock()->OnInventorySlotsUpdate(cat);
} }
} }
@ -441,7 +441,7 @@ void Menu::MerchantInventorySlotsUpdated(ITCategory cat){
void Menu::AddInventoryListener(std::weak_ptr<MenuComponent>component,ITCategory category){ void Menu::AddInventoryListener(std::weak_ptr<MenuComponent>component,ITCategory category){
if(inventoryListeners.count(category)){ if(inventoryListeners.count(category)){
std::vector<std::weak_ptr<MenuComponent>>&listenerList=inventoryListeners.at(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!!") 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); 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){ void Menu::AddMerchantInventoryListener(std::weak_ptr<MenuComponent>component,ITCategory category){
if(merchantInventoryListeners.count(category)){ if(merchantInventoryListeners.count(category)){
std::vector<std::weak_ptr<MenuComponent>>&listenerList=merchantInventoryListeners.at(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!!") 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); 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){ 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!!") 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); equipStatListeners.push_back(component);
@ -542,7 +542,7 @@ void Menu::LockInListeners(){
} }
void Menu::AddChapterListener(std::weak_ptr<MenuComponent>component){ 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!!") 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); chapterListeners.push_back(component);

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

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

@ -211,7 +211,7 @@ void MenuComponent::_OnMouseOut(){
if(runHoverFunctions){ if(runHoverFunctions){
if(hoverState){ if(hoverState){
hoverState=false; 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(); OnMouseOut();
} }
} }
@ -221,7 +221,7 @@ void MenuComponent::_OnHover(){
if(hovered){ if(hovered){
if(runHoverFunctions&&!hoverState){ if(runHoverFunctions&&!hoverState){
hoverState=true; 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(); OnHover();
} }
} }

@ -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", 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){ [](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,"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,"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"); Component<MenuLabel>(BUY_ITEM,"Amount to buy Amount Label")->SetLabel("1");
@ -111,7 +111,7 @@ void Menu::InitializeMerchantWindow(){
return true; return true;
}, },
[](MenuFuncData data){ [](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; return true;
}, },
[](MenuFuncData data){ [](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", 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){ [](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()){ if(item.lock()->GetItem().lock()->CanBeSold()){
Component<ItemMenuLabel>(SELL_ITEM,"Item Sell Header")->SetItem(item.lock()->GetItem()); 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())); 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; return true;
}, },
[](MenuFuncData data){ [](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; return true;
}, },
[](MenuFuncData data){ [](MenuFuncData data){

@ -1069,7 +1069,7 @@ void Player::SetMoney(uint32_t newMoney){
} }
} }
void Player::AddMoneyListener(std::weak_ptr<MenuComponent>component){ 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!!") 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); moneyListeners.push_back(component);

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

@ -224,7 +224,7 @@ const void SaveFile::UpdateSaveGameData(){
for(size_t i=0;i<saveFileCount;i++){ for(size_t i=0;i<saveFileCount;i++){
if(metadata.HasProperty(std::format("save{}",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){ 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(); saveFileID=comp.lock()->getSaveFileID();
SaveFile::LoadGame(); SaveFile::LoadGame();
return true; return true;

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

@ -57,24 +57,14 @@ public:
ERR("WARNING! Toggle group for this component was set twice for some reason! THIS SHOULD NOT BE HAPPENING!") ERR("WARNING! Toggle group for this component was set twice for some reason! THIS SHOULD NOT BE HAPPENING!")
} }
toggleGroupInitialized=true; 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){ inline void SetToggleGroup(std::vector<std::weak_ptr<IToggleable>>toggleGroup){
this->toggleGroup=toggleGroup; this->toggleGroup=toggleGroup;
SetToggleGroup(); 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: protected:
std::vector<std::weak_ptr<IToggleable>>toggleGroup; std::vector<std::weak_ptr<IToggleable>>toggleGroup;
private: private:
bool selected=false; bool selected=false;
bool toggleGroupInitialized=false; bool toggleGroupInitialized=false;
inline static std::vector<std::weak_ptr<IToggleable>>uninitializedToggleGroupItems;
}; };

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

Loading…
Cancel
Save