Added Merchant/Buy/Sell Menu windows. Added sorted item callbacks for traveling merchant inventory modifications.
This commit is contained in:
@@ -45,7 +45,7 @@ INCLUDE_game
|
||||
using A=Attribute;
|
||||
|
||||
MenuComponent::MenuComponent(geom2d::rect<float>rect,std::string label,MenuFunc onClick,ButtonAttr attributes)
|
||||
:rect(rect),originalPos(rect.pos),label(label),menuDest(MenuType::ENUM_END),onClick(onClick),hoverEffect(0),selectable(!(attributes&ButtonAttr::UNSELECTABLE)),selectableViaKeyboard(!(attributes&ButtonAttr::UNSELECTABLE_VIA_KEYBOARD)),memoryLeakInfo(Menu::GetMemoryLeakReportInfo()){
|
||||
:rect(rect),originalPos(rect.pos),label(label),menuDest(MenuType::ENUM_END),onClick(onClick),hoverEffect(0),selectable(!(attributes&ButtonAttr::UNSELECTABLE)),selectableViaKeyboard(!(attributes&ButtonAttr::UNSELECTABLE_VIA_KEYBOARD)),memoryLeakInfo(Menu::GetMemoryLeakReportInfo()),fitToLabel(attributes&ButtonAttr::FIT_TO_LABEL){
|
||||
Menu::unhandledComponents.push_back(this);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,14 @@ void MenuComponent::DrawDecal(ViewPort&window,bool focused){
|
||||
window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET)+vf2d{0,rect.size.y-1+1},{rect.size.x+1,1});
|
||||
}
|
||||
if(showDefaultLabel){
|
||||
window.DrawStringPropDecal(rect.pos+V(A::DRAW_OFFSET)+rect.size/2-vf2d(game->GetTextSizeProp(label))/2.f*labelScaling,label,WHITE,labelScaling);
|
||||
vf2d adjustedScale=labelScaling;
|
||||
if(fitToLabel){
|
||||
float sizeRatio=((game->GetTextSizeProp(label)*adjustedScale).x)/(rect.size.x-2);
|
||||
if(sizeRatio>1){
|
||||
adjustedScale.x/=sizeRatio;
|
||||
}
|
||||
}
|
||||
window.DrawStringPropDecal(rect.pos+V(A::DRAW_OFFSET)+rect.size/2-vf2d(game->GetTextSizeProp(label))/2.f*adjustedScale,label,WHITE,adjustedScale);
|
||||
}
|
||||
if(selected){
|
||||
switch(selectionType){
|
||||
|
||||
Reference in New Issue
Block a user