Implemented Crafting enhancement window, item enhancement checks, and enhancement implementation done.

This commit is contained in:
2023-12-28 06:10:46 -06:00
parent 8f41870b46
commit 64694e1b63
15 changed files with 366 additions and 14 deletions
+20 -5
View File
@@ -49,9 +49,10 @@ protected:
float scale=1;
bool shadow=false;
bool centered=true;
bool proportional=true;
public:
inline MenuLabel(geom2d::rect<float>rect,std::string label,float scale=1,ComponentAttr attributes=ComponentAttr::NONE)
:MenuComponent(rect,label,MenuFunc{},ButtonAttr::UNSELECTABLE|ButtonAttr::UNSELECTABLE_VIA_KEYBOARD),scale(scale),centered(!(attributes&ComponentAttr::LEFT_ALIGN)),shadow(attributes&ComponentAttr::SHADOW){
:MenuComponent(rect,label,MenuFunc{},ButtonAttr::UNSELECTABLE|ButtonAttr::UNSELECTABLE_VIA_KEYBOARD),scale(scale),centered(!(attributes&ComponentAttr::LEFT_ALIGN)),shadow(attributes&ComponentAttr::SHADOW),proportional(!(attributes&ComponentAttr::FIXED_WIDTH_FONT)){
border=attributes&ComponentAttr::OUTLINE;
this->background=attributes&ComponentAttr::BACKGROUND;
showDefaultLabel=false;
@@ -67,14 +68,20 @@ protected:
inline virtual void DrawDecal(ViewPort&window,bool focused)override{
MenuComponent::DrawDecal(window,focused);
vf2d adjustedScale={scale,scale};
vf2d labelTextSize=vf2d(game->GetWrappedTextSizeProp(label,rect.size.x,adjustedScale));
vf2d labelTextSize=
proportional?
vf2d(game->GetWrappedTextSizeProp(label,rect.size.x,adjustedScale)):
vf2d(game->GetWrappedTextSize(label,rect.size.x,adjustedScale));
if(fitToLabel){
float sizeRatio=((labelTextSize*adjustedScale).x)/(rect.size.x-2);
if(sizeRatio>1){
adjustedScale.x/=sizeRatio;
}
labelTextSize=vf2d(game->GetTextSizeProp(label)*adjustedScale);
labelTextSize=
proportional?
vf2d(game->GetTextSizeProp(label)*adjustedScale):
vf2d(game->GetTextSize(label)*adjustedScale);
}
vf2d drawPos=rect.middle()-vf2d{labelTextSize}/2; //Assume centered.
@@ -83,9 +90,17 @@ protected:
}
if(shadow){
window.DrawShadowStringPropDecal(drawPos,label,WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x,1.0f);
if(proportional){
window.DrawShadowStringPropDecal(drawPos,label,WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x,1.0f);
}else{
window.DrawShadowStringDecal(drawPos,label,WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x,1.0f);
}
}else{
window.DrawStringPropDecal(drawPos,label,WHITE,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x,1.0f);
if(proportional){
window.DrawStringPropDecal(drawPos,label,WHITE,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x,1.0f);
}else{
window.DrawStringDecal(drawPos,label,WHITE,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x,1.0f);
}
}
}
};