diff --git a/Crawler/CharacterMenuWindow.cpp b/Crawler/CharacterMenuWindow.cpp index 09717f4a..a1325921 100644 --- a/Crawler/CharacterMenuWindow.cpp +++ b/Crawler/CharacterMenuWindow.cpp @@ -135,7 +135,7 @@ void Menu::InitializeCharacterMenuWindow(){ equipList->RemoveAllComponents(); for(int counter=0;Item&it:availableEquipment){ Item&itemInvRef=Inventory::GetItem(it.Name()); - auto equip=equipList->ADD("Equip Item "+std::to_string(counter),RowItemDisplay)({{2,2+counter*28.f},{120-12,28}},itemInvRef, + auto equip=equipList->ADD("Equip Item "+std::to_string(counter),RowItemDisplay)({{2,2+counter*28.f},{120-15,28}},itemInvRef, [](MenuFuncData data){ RowItemDisplay*comp=dynamic_cast(data.component); if(comp!=nullptr){ diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 8ccd2c0a..7a8fc540 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -196,6 +196,7 @@ bool Crawler::OnUserCreate(){ Inventory::AddItem("Copper Pants"); Inventory::AddItem("Shell Helmet"); Inventory::AddItem("Shell Armor"); + Inventory::AddItem("Bone Armor"); Inventory::AddItem("Shell Gloves"); Inventory::AddItem("Shell Shoes"); Inventory::AddItem("Bone Pants"); diff --git a/Crawler/InventoryScrollableWindowComponent.h b/Crawler/InventoryScrollableWindowComponent.h index 181906e1..9938afeb 100644 --- a/Crawler/InventoryScrollableWindowComponent.h +++ b/Crawler/InventoryScrollableWindowComponent.h @@ -117,7 +117,7 @@ protected: i--; //Subtract one from the index so we don't accidently skip slots. } } - bounds=CalculateBounds(); //Recalculate the bounds as it's possible the width/height of the component has changed. + CalculateBounds(); //Recalculate the bounds as it's possible the width/height of the component has changed. } virtual inline void OnInventorySlotsUpdate(ITCategory cat)override{ size_t invSize=Inventory::get(cat).size(); diff --git a/Crawler/ScrollableWindowComponent.h b/Crawler/ScrollableWindowComponent.h index 5b9d53bc..edef1f79 100644 --- a/Crawler/ScrollableWindowComponent.h +++ b/Crawler/ScrollableWindowComponent.h @@ -71,8 +71,8 @@ public: } } virtual inline void RemoveButton(MenuComponent*button){ - std::vector&buttonList=Menu::menus[button->parentMenu]->buttons.at(int(button->GetPos().y)); - std::vector&keyboardButtonList=Menu::menus[button->parentMenu]->keyboardButtons.at(int(button->GetPos().y)); + std::vector&buttonList=Menu::menus[button->parentMenu]->buttons.at(int(button->originalPos.y)); + std::vector&keyboardButtonList=Menu::menus[button->parentMenu]->keyboardButtons.at(int(button->originalPos.y)); size_t removedCount=0; removedCount+=std::erase(buttonList,button); removedCount+=std::erase(keyboardButtonList,button); @@ -80,19 +80,20 @@ public: std::cout<<"WARNING! Attempted to remove buttons from button listing, but not found!"; } if(buttonList.size()==0){ - if(!Menu::menus[button->parentMenu]->buttons.erase(int(button->GetPos().y))){ - ERR("WARNING! Attempted to erase key "<GetPos().y<<" from button map, but the list still exists!") + if(!Menu::menus[button->parentMenu]->buttons.erase(int(button->originalPos.y))){ + ERR("WARNING! Attempted to erase key "<originalPos.y<<" from button map, but the list still exists!") } } if(keyboardButtonList.size()==0){ - if(!Menu::menus[button->parentMenu]->keyboardButtons.erase(int(button->GetPos().y))){ - ERR("WARNING! Attempted to erase key "<GetPos().y<<" from button map, but the list still exists!") + if(!Menu::menus[button->parentMenu]->keyboardButtons.erase(int(button->originalPos.y))){ + ERR("WARNING! Attempted to erase key "<originalPos.y<<" from button map, but the list still exists!") } } Menu::menus[button->parentMenu]->components.erase(button->GetName()); components.erase(std::find(components.begin(),components.end(),button)); Menu::menus[button->parentMenu]->RecalculateComponentCount(); delete button; + CalculateBounds(); } virtual inline void SetScrollAmount(vf2d scrollOffset){ this->scrollOffset=scrollOffset; @@ -106,8 +107,8 @@ public: protected: virtual inline void AfterCreate()override{ //Let's use the internal name of this component to add unique names for sub-components. - upButton=Menu::menus[parentMenu]->ADD(name+vf2d(rect.pos+vf2d{rect.size.x-12,0}).str()+"_"+vf2d(12,12).str(),MenuComponent)({rect.pos+vf2d{rect.size.x-12,0},{12,12}},"^",[&](MenuFuncData dat){SetScrollAmount(GetScrollAmount()+vf2d{0,"ThemeGlobal.MenuButtonScrollSpeed"_F});return true;},ButtonAttr::UNSELECTABLE_VIA_KEYBOARD)DEPTH -1 END; - downButton=Menu::menus[parentMenu]->ADD(name+vf2d(rect.pos+rect.size-vf2d{12,12}).str()+"_"+vf2d(12,12).str(),MenuComponent)({rect.pos+rect.size-vf2d{12,12},{12,12}},"v",[&](MenuFuncData dat){SetScrollAmount(GetScrollAmount()-vf2d{0,"ThemeGlobal.MenuButtonScrollSpeed"_F});return true;},ButtonAttr::UNSELECTABLE_VIA_KEYBOARD)DEPTH -1 END; + upButton=Menu::menus[parentMenu]->ADD(name+vf2d(rect.pos+vf2d{rect.size.x-12,0}).str()+"_"+vf2d(12,12).str(),MenuComponent)({rect.pos+vf2d{rect.size.x-12,0},{12,12}},"^",[&](MenuFuncData dat){SetScrollAmount(GetScrollAmount()+vf2d{0,"ThemeGlobal.MenuButtonScrollSpeed"_F});return true;},ButtonAttr::UNSELECTABLE_VIA_KEYBOARD)DEPTH depth-1 END; + downButton=Menu::menus[parentMenu]->ADD(name+vf2d(rect.pos+rect.size-vf2d{12,12}).str()+"_"+vf2d(12,12).str(),MenuComponent)({rect.pos+rect.size-vf2d{12,12},{12,12}},"v",[&](MenuFuncData dat){SetScrollAmount(GetScrollAmount()-vf2d{0,"ThemeGlobal.MenuButtonScrollSpeed"_F});return true;},ButtonAttr::UNSELECTABLE_VIA_KEYBOARD)DEPTH depth-1 END; subWindow=ViewPort::rectViewPort({},rect.size,Menu::menus[parentMenu]->pos+rect.pos); if(upButton){upButton->Enable(!disabled);} if(downButton){downButton->Enable(!disabled);} @@ -137,7 +138,6 @@ protected: float spaceBetweenTopAndBottomArrows=rect.size.y-24; float viewHeight=rect.size.y; - float totalContentHeight=bounds.size.y; if(totalContentHeight==0)totalContentHeight=1; float scrollBarScale=(spaceBetweenTopAndBottomArrows/totalContentHeight); @@ -205,8 +205,8 @@ protected: return geom2d::overlaps(geom2d::rect{Menu::menus[parentMenu]->pos+rect.pos+child->rect.pos,child->rect.size},game->GetMousePos()); } //Calculates the bounds of all components. - geom2d::rect inline CalculateBounds(){ - geom2d::rectbounds; + inline void CalculateBounds(){ + bounds={}; for(MenuComponent*component:components){ if(component->rect.pos.xrect.pos.x; @@ -227,7 +227,6 @@ protected: bounds.size.y+=sizeIncrease; } } - return bounds; } public: template @@ -236,24 +235,7 @@ public: button->renderInMain=false; //Now we are in control! button->parentComponent=this; - if(button->rect.pos.xrect.pos.x; - bounds.size.x+=sizeIncrease; - bounds.pos.x=button->rect.pos.x; - } - if(button->rect.right().start.x>bounds.right().start.x){ - float sizeIncrease=button->rect.right().start.x-bounds.right().start.x; - bounds.size.x+=sizeIncrease; - } - if(button->rect.pos.yrect.pos.y; - bounds.size.y+=sizeIncrease; - bounds.pos.y=button->rect.pos.y; - } - if(button->rect.bottom().start.y>bounds.bottom().start.y){ - float sizeIncrease=button->rect.bottom().start.y-bounds.bottom().start.y; - bounds.size.y+=sizeIncrease; - } + CalculateBounds(); Menu::menus[parentMenu]->_AddComponent(key,button); return button; diff --git a/Crawler/Version.h b/Crawler/Version.h index 144af1bf..1efd0bc3 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 4009 +#define VERSION_BUILD 4019 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/assets/config/items/ItemDatabase.txt b/Crawler/assets/config/items/ItemDatabase.txt index 0aa98e1b..0b572698 100644 --- a/Crawler/assets/config/items/ItemDatabase.txt +++ b/Crawler/assets/config/items/ItemDatabase.txt @@ -113,7 +113,8 @@ ItemDatabase ItemScript = Restore HP Restore = 1 Description = Does nothing apparently. - ItemCategory = Consumables + ItemCategory = Equipment + Slot = Armor Cooldown Time = 5.0 Cast Time = 0.0 } @@ -122,7 +123,8 @@ ItemDatabase ItemScript = Restore HP Restore = 1 Description = Does nothing apparently. - ItemCategory = Consumables + ItemCategory = Equipment + Slot = Armor Cooldown Time = 5.0 Cast Time = 0.0 } @@ -131,7 +133,8 @@ ItemDatabase ItemScript = Restore HP Restore = 1 Description = Does nothing apparently. - ItemCategory = Consumables + ItemCategory = Equipment + Slot = Armor Cooldown Time = 5.0 Cast Time = 0.0 }