From 11e2aa0fadab36be8d2fcf88c7f839f714277845 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 21 Nov 2023 21:35:21 -0600 Subject: [PATCH] PopupMenuLabels respect parent menu's position. --- Crawler/LevelCompleteWindow.cpp | 4 ++-- Crawler/PopupMenuLabel.h | 22 +++++++++++----------- Crawler/Version.h | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Crawler/LevelCompleteWindow.cpp b/Crawler/LevelCompleteWindow.cpp index db73cdf8..269fca60 100644 --- a/Crawler/LevelCompleteWindow.cpp +++ b/Crawler/LevelCompleteWindow.cpp @@ -74,13 +74,13 @@ void Menu::InitializeLevelCompleteWindow(){ levelCompleteWindow->AddComponent("Next Button",nextButton); PopupMenuLabel*monsterLootPopupItemName=NEW PopupMenuLabel(LEVEL_COMPLETE,{{0,108},{windowSize.size.x-80.f,12}},"",1.0f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND); - PopupMenuLabel*monsterLootPopupItemDescription=NEW PopupMenuLabel(LEVEL_COMPLETE,{{0,120},{windowSize.size.x-80.f,60}},"",1.0f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW|ComponentAttr::BACKGROUND); + PopupMenuLabel*monsterLootPopupItemDescription=NEW PopupMenuLabel(LEVEL_COMPLETE,{{0,120},{windowSize.size.x-80.f,60}},"",1.0f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND); levelCompleteWindow->AddComponent("Monster Loot Popup Item Name",monsterLootPopupItemName); levelCompleteWindow->AddComponent("Monster Loot Popup Item Description",monsterLootPopupItemDescription); PopupMenuLabel*stageLootPopupItemName=NEW PopupMenuLabel(LEVEL_COMPLETE,{{0,32},{windowSize.size.x-80.f,12}},"",1.0f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND); - PopupMenuLabel*stageLootPopupItemDescription=NEW PopupMenuLabel(LEVEL_COMPLETE,{{0,44},{windowSize.size.x-80.f,72}},"",1.0f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW|ComponentAttr::BACKGROUND); + PopupMenuLabel*stageLootPopupItemDescription=NEW PopupMenuLabel(LEVEL_COMPLETE,{{0,44},{windowSize.size.x-80.f,60}},"",1.0f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND); levelCompleteWindow->AddComponent("Stage Loot Popup Item Name",stageLootPopupItemName); levelCompleteWindow->AddComponent("Stage Loot Popup Item Description",stageLootPopupItemDescription); diff --git a/Crawler/PopupMenuLabel.h b/Crawler/PopupMenuLabel.h index 422d91f0..73dd9f04 100644 --- a/Crawler/PopupMenuLabel.h +++ b/Crawler/PopupMenuLabel.h @@ -54,25 +54,25 @@ protected: virtual void inline DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{ if(label.length()>0){ MenuLabel::DrawDecal(game,parentPos,focused); - std::string wrappedText=util::WrapText(game,label,rect.size.x,true,{scale,scale}); - vf2d drawPos=parentPos+rect.middle()-vf2d{game->GetTextSizeProp(wrappedText)}*float(scale)/2; //Assume centered. + std::string wrappedText=util::WrapText(game,label,rect.size.x-1,true,{scale,scale}); + vf2d drawPos=Menu::menus.at(parentMenu)->pos+parentPos+rect.middle()-vf2d{game->GetTextSizeProp(wrappedText)}*float(scale)/2; //Assume centered. if(!centered){ - drawPos=vf2d{rect.pos.x+2,rect.middle().y-game->GetTextSizeProp(wrappedText).y/2}+parentPos; //We should at least vertically align here. - } - if(shadow){ - game->DrawShadowStringPropDecal(drawPos,wrappedText,WHITE,BLACK,{scale,scale}); - }else{ - game->DrawStringPropDecal(drawPos,wrappedText,WHITE,{scale,scale}); + drawPos=Menu::menus.at(parentMenu)->pos+vf2d{rect.pos.x+2,rect.middle().y-game->GetTextSizeProp(wrappedText).y/2}+parentPos; //We should at least vertically align here. } if(background){ - game->FillRectDecal(rect.pos+parentPos,rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),hoverEffect/"ThemeGlobal.HighlightTime"_F)); + game->FillRectDecal(Menu::menus.at(parentMenu)->pos+rect.pos+parentPos,rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),hoverEffect/"ThemeGlobal.HighlightTime"_F)); } if(border){ - game->DrawRectDecal(rect.pos+parentPos,rect.size); + game->DrawRectDecal(Menu::menus.at(parentMenu)->pos+rect.pos+parentPos,rect.size); } if(showDefaultLabel){ - game->DrawStringPropDecal(rect.pos+parentPos+rect.size/2-game->GetTextSizeProp(label)/2,label); + game->DrawStringPropDecal(Menu::menus.at(parentMenu)->pos+rect.pos+parentPos+rect.size/2-game->GetTextSizeProp(label)/2,label); } + if(shadow){ + game->DrawShadowStringPropDecal(drawPos,wrappedText,WHITE,BLACK,{scale,scale}); + }else{ + game->DrawStringPropDecal(drawPos,wrappedText,WHITE,{scale,scale}); + } } } }; \ No newline at end of file diff --git a/Crawler/Version.h b/Crawler/Version.h index 3f2c8046..00bc6463 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -35,7 +35,7 @@ SUCH DAMAGE. #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 2987 +#define VERSION_BUILD 2992 #define stringify(a) stringify_(a) #define stringify_(a) #a