From fe8cbb022ac840f3f808a69ba345470221c6be96 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sat, 4 Nov 2023 23:02:00 -0500 Subject: [PATCH] Fixed inventory window display bugs using old parent position code for rendering. --- Crawler/Crawler.vcxproj | 1 + Crawler/Crawler.vcxproj.filters | 3 +++ Crawler/InventoryWindow.cpp | 2 +- Crawler/OverworldDisplayWindow.cpp | 0 Crawler/ScrollableWindowComponent.h | 6 +++--- Crawler/State_OverworldMap.cpp | 1 + Crawler/Version.h | 2 +- 7 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 Crawler/OverworldDisplayWindow.cpp diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj index a216a84e..fb575043 100644 --- a/Crawler/Crawler.vcxproj +++ b/Crawler/Crawler.vcxproj @@ -341,6 +341,7 @@ + diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters index 4df69dea..6d287a22 100644 --- a/Crawler/Crawler.vcxproj.filters +++ b/Crawler/Crawler.vcxproj.filters @@ -383,6 +383,9 @@ Source Files + + Source Files\Interface + diff --git a/Crawler/InventoryWindow.cpp b/Crawler/InventoryWindow.cpp index afa92aa5..c2d840ba 100644 --- a/Crawler/InventoryWindow.cpp +++ b/Crawler/InventoryWindow.cpp @@ -30,7 +30,7 @@ void Menu::InitializeInventoryWindow(){ //We don't have to actually populate the inventory list because now when an item gets added, it will automatically add the correct component in for us. - MenuLabel*itemNameLabel=new MenuLabel{INVENTORY,geom2d::rect(vf2d{2,float(initialInvHeight*totalSpacing-4)},windowSize),"",1,false,true}; + MenuLabel*itemNameLabel=new MenuLabel{INVENTORY,geom2d::rect(vf2d{2,float(initialInvHeight*totalSpacing+itemSpacing-16)},{windowSize.x-4,windowSize.y-108}),"",1,false,true}; inventoryWindow->AddComponent("itemName",itemNameLabel); MenuLabel*itemDescriptionLabel=new MenuLabel{INVENTORY,geom2d::rect(vf2d{2,float(initialInvHeight*totalSpacing+itemSpacing)},{windowSize.x-4,windowSize.y-108}),"",1,true,true}; inventoryWindow->AddComponent("itemDescription",itemDescriptionLabel); diff --git a/Crawler/OverworldDisplayWindow.cpp b/Crawler/OverworldDisplayWindow.cpp new file mode 100644 index 00000000..e69de29b diff --git a/Crawler/ScrollableWindowComponent.h b/Crawler/ScrollableWindowComponent.h index 2061b5a9..68030260 100644 --- a/Crawler/ScrollableWindowComponent.h +++ b/Crawler/ScrollableWindowComponent.h @@ -122,11 +122,11 @@ protected: virtual inline void DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{ MenuComponent::DrawDecal(game,parentPos,focused); - game->DrawRectDecal(rect.pos+parentPos,rect.size); + game->DrawRectDecal(rect.pos+Menu::menus[parentMenu]->pos,rect.size); for(MenuComponent*component:components){ - component->_DrawDecal(game,rect.pos+parentPos+V(A::SCROLL_OFFSET),focused); + component->_DrawDecal(game,rect.pos+Menu::menus[parentMenu]->pos+V(A::SCROLL_OFFSET),focused); } - DrawScrollbar(game,parentPos,focused); + DrawScrollbar(game,Menu::menus[parentMenu]->pos,focused); } virtual bool GetHoverState(Crawler*game,MenuComponent*child)override{ return geom2d::overlaps(geom2d::rect{Menu::menus[parentMenu]->pos+rect.pos+child->rect.pos+V(A::SCROLL_OFFSET),child->rect.size},game->GetMousePos()); diff --git a/Crawler/State_OverworldMap.cpp b/Crawler/State_OverworldMap.cpp index 6d0f5ae9..5bccd0e7 100644 --- a/Crawler/State_OverworldMap.cpp +++ b/Crawler/State_OverworldMap.cpp @@ -38,6 +38,7 @@ void State_OverworldMap::OnUserUpdate(Crawler*game){ for(ConnectionPoint&cp:connections){ if(game->GetMouse(Mouse::LEFT).bPressed&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)){ + Menu::OpenMenu(MenuType::INVENTORY); for(int neighborInd:currentConnectionPoint->neighbors){ if(neighborInd==-1)continue; ConnectionPoint&neighbor=ConnectionPointFromIndex(neighborInd); diff --git a/Crawler/Version.h b/Crawler/Version.h index f03554c3..80a50198 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 2527 +#define VERSION_BUILD 2536 #define stringify(a) stringify_(a) #define stringify_(a) #a