PopupMenuLabels respect parent menu's position.

pull/28/head
sigonasr2 1 year ago
parent 195cc31a7b
commit 11e2aa0fad
  1. 4
      Crawler/LevelCompleteWindow.cpp
  2. 22
      Crawler/PopupMenuLabel.h
  3. 2
      Crawler/Version.h

@ -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);

@ -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});
}
}
}
};

@ -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

Loading…
Cancel
Save