|
|
@ -1,5 +1,6 @@ |
|
|
|
#include "Textbox.h" |
|
|
|
#include "Textbox.h" |
|
|
|
#include "olcUTIL_Geometry2D.h" |
|
|
|
#include "olcUTIL_Geometry2D.h" |
|
|
|
|
|
|
|
#include "util.h" |
|
|
|
|
|
|
|
|
|
|
|
Textbox::Textbox(){}; |
|
|
|
Textbox::Textbox(){}; |
|
|
|
|
|
|
|
|
|
|
@ -66,9 +67,13 @@ void Textbox::Update(PixelGameEngine*pge){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Textbox::Draw(PixelGameEngine*pge,Resources&resources){ |
|
|
|
void Textbox::Draw(PixelGameEngine*pge,Resources&resources,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){ |
|
|
|
if(visible){ |
|
|
|
if(visible){ |
|
|
|
geom2d::rect<float>boxRect={pos-vf2d{3,3},maxSize+vf2d{6,6}}; |
|
|
|
geom2d::rect<float>boxRect={pos-vf2d{3,3},maxSize+vf2d{6,6}}; |
|
|
|
|
|
|
|
if(resourceCost.size()>0){ |
|
|
|
|
|
|
|
boxRect.size.x+=24; |
|
|
|
|
|
|
|
boxRect.size.y=std::max(36.f,boxRect.size.y); |
|
|
|
|
|
|
|
} |
|
|
|
if(boxRect.bottom().start.y>=pge->ScreenHeight()){ |
|
|
|
if(boxRect.bottom().start.y>=pge->ScreenHeight()){ |
|
|
|
boxRect.pos-={0,boxRect.bottom().start.y-pge->ScreenHeight()}; |
|
|
|
boxRect.pos-={0,boxRect.bottom().start.y-pge->ScreenHeight()}; |
|
|
|
} |
|
|
|
} |
|
|
@ -81,10 +86,42 @@ void Textbox::Draw(PixelGameEngine*pge,Resources&resources){ |
|
|
|
if(boxRect.left().start.x<0){ |
|
|
|
if(boxRect.left().start.x<0){ |
|
|
|
boxRect.pos+={-boxRect.left().start.x,0}; |
|
|
|
boxRect.pos+={-boxRect.left().start.x,0}; |
|
|
|
} |
|
|
|
} |
|
|
|
pge->FillRectDecal(boxRect.pos,maxSize+vf2d{6,6},VERY_DARK_GREEN); |
|
|
|
pge->FillRectDecal(boxRect.pos,maxSize+vf2d{6,6},backCol); |
|
|
|
pge->DrawRectDecal(boxRect.pos+vf2d{1,1},maxSize+vf2d{4,4},WHITE); |
|
|
|
pge->DrawRectDecal(boxRect.pos+vf2d{1,1},maxSize+vf2d{4,4},WHITE); |
|
|
|
pge->DrawShadowStringPropDecal(boxRect.pos+vf2d{3,3},displayHeaderText,{245, 218, 66}); |
|
|
|
pge->DrawShadowStringPropDecal(boxRect.pos+vf2d{3,3},displayHeaderText,{245, 218, 66}); |
|
|
|
pge->DrawShadowStringPropDecal(boxRect.pos+vf2d{3.f,float(3+pge->GetTextSizeProp(displayHeaderText).y)},displayText,{220,220,220}); |
|
|
|
pge->DrawShadowStringPropDecal(boxRect.pos+vf2d{3.f,float(3+pge->GetTextSizeProp(displayHeaderText).y)},displayText,{220,220,220}); |
|
|
|
|
|
|
|
if(resourceCost.size()>0){ |
|
|
|
|
|
|
|
geom2d::rect<float>resourceBoxRect={boxRect.pos+vf2d{6+maxSize.x,6},{36,36}}; |
|
|
|
|
|
|
|
pge->FillRectDecal(resourceBoxRect.pos,resourceBoxRect.size,backCol); |
|
|
|
|
|
|
|
pge->DrawRectDecal(resourceBoxRect.pos+vf2d{1,1},resourceBoxRect.size-vf2d{2,2},WHITE); |
|
|
|
|
|
|
|
vf2d contentPos=resourceBoxRect.pos+vf2d{3,3}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pixel drawcol=GREY,shadowCol={66, 164, 245}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto DrawResourceAmount=[&](int index,int cost,int resourceAmt){ |
|
|
|
|
|
|
|
drawcol=resourceAmt>=cost?GREY:RED; |
|
|
|
|
|
|
|
shadowCol=drawcol==GREY?VERY_DARK_BLUE:VERY_DARK_RED; |
|
|
|
|
|
|
|
vf2d textScale = {0.4,0.4}; |
|
|
|
|
|
|
|
std::string displayString = std::to_string(resourceAmt)+" / "; |
|
|
|
|
|
|
|
if(resourceAmt<cost){ |
|
|
|
|
|
|
|
pge->FillRectDecal(contentPos+vf2d{0,float(index*6)},vf2d{resourceBoxRect.size.x-6,6},{160,0,0,192}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
pge->DrawShadowStringDecal(contentPos+vf2d{12.f,float(index*6)+1},displayString,drawcol,shadowCol,textScale,0.6); |
|
|
|
|
|
|
|
pge->DrawShadowStringDecal(contentPos+vf2d{12.f+pge->GetTextSize(displayString).x*textScale.x+2,float(index*6)+1},std::to_string(cost),drawcol,shadowCol,{0.4,0.4},0.6); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DrawResourceAmount(0,util::GetHealthCost(resourceCost),resources.health); |
|
|
|
|
|
|
|
DrawResourceAmount(1,util::GetAtkSpdCost(resourceCost),resources.atkSpd); |
|
|
|
|
|
|
|
DrawResourceAmount(2,util::GetMoveSpdCost(resourceCost),resources.moveSpd); |
|
|
|
|
|
|
|
DrawResourceAmount(3,util::GetRangeCost(resourceCost),resources.range); |
|
|
|
|
|
|
|
DrawResourceAmount(4,util::GetProcedureCost(resourceCost),resources.procedure); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pge->DrawDecal(contentPos+vf2d{0,0*6},IMAGES[RESOURCE]->Decal(),{0.5,0.5},CONSTANT::HEALTH_COLOR); |
|
|
|
|
|
|
|
pge->DrawDecal(contentPos+vf2d{0,1*6},IMAGES[RESOURCE]->Decal(),{0.5,0.5},CONSTANT::ATKSPD_COLOR); |
|
|
|
|
|
|
|
pge->DrawDecal(contentPos+vf2d{0,2*6},IMAGES[RESOURCE]->Decal(),{0.5,0.5},CONSTANT::MOVESPD_COLOR); |
|
|
|
|
|
|
|
pge->DrawDecal(contentPos+vf2d{0,3*6},IMAGES[RESOURCE]->Decal(),{0.5,0.5},CONSTANT::RANGE_COLOR); |
|
|
|
|
|
|
|
pge->DrawDecal(contentPos+vf2d{0,4*6},IMAGES[RESOURCE]->Decal(),{0.5,0.5},CONSTANT::PROCEDURE_COLOR); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -103,12 +140,16 @@ void Textbox::SetVisible(bool visible){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Textbox::UpdateAndDraw(vf2d pos,PixelGameEngine*pge,Resources&resources){ |
|
|
|
void Textbox::UpdateAndDraw(vf2d pos,PixelGameEngine*pge,Resources&resources,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){ |
|
|
|
UpdatePosition(pos); |
|
|
|
UpdatePosition(pos); |
|
|
|
Update(pge); |
|
|
|
Update(pge); |
|
|
|
Draw(pge,resources); |
|
|
|
Draw(pge,resources,IMAGES); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vf2d Textbox::GetSize(){ |
|
|
|
vf2d Textbox::GetSize(){ |
|
|
|
return maxSize; |
|
|
|
return maxSize; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Textbox::SetBackgroundColor(Pixel col){ |
|
|
|
|
|
|
|
backCol=col; |
|
|
|
} |
|
|
|
} |