Padding and auto-expanding height.

CorrectiveAction
sigonasr2 1 year ago
parent c5a85c7fcd
commit 027ec20449
  1. 7
      olcCodeJam2023Entry/Textbox.cpp
  2. 2
      olcCodeJam2023Entry/Textbox.h
  3. 1
      olcCodeJam2023Entry/VirusAttack.cpp

@ -44,6 +44,7 @@ void Textbox::Update(PixelGameEngine*pge){
}
displayText+=text[textboxMarker+1];
textboxMarker++;
maxSize.y=std::max(maxSize.y,float(pge->GetTextSizeProp(tempText).y));
}
lastLetterTime=letterDisplayDelay;
}
@ -52,7 +53,7 @@ void Textbox::Update(PixelGameEngine*pge){
void Textbox::Draw(PixelGameEngine*pge,Resources&resources){
if(visible){
geom2d::rect<float>boxRect={pos-vf2d{2,2},maxSize+vf2d{4,4}};
geom2d::rect<float>boxRect={pos-vf2d{3,3},maxSize+vf2d{6,6}};
if(boxRect.bottom().start.y>=pge->ScreenHeight()){
boxRect.pos-={0,boxRect.bottom().start.y-pge->ScreenHeight()};
}
@ -65,8 +66,8 @@ void Textbox::Draw(PixelGameEngine*pge,Resources&resources){
if(boxRect.left().start.x<0){
boxRect.pos+={-boxRect.left().start.x,0};
}
pge->FillRectDecal(boxRect.pos,maxSize+vf2d{4,4},VERY_DARK_GREEN);
pge->DrawRectDecal(boxRect.pos+vf2d{1,1},maxSize+vf2d{3,3},WHITE);
pge->FillRectDecal(boxRect.pos,maxSize+vf2d{6,6},VERY_DARK_GREEN);
pge->DrawRectDecal(boxRect.pos+vf2d{1,1},maxSize+vf2d{4,4},WHITE);
pge->DrawShadowStringPropDecal(boxRect.pos+vf2d{3,3},displayText,{220,220,220});
}
}

@ -19,7 +19,7 @@ class Textbox{
bool visible=true;
public:
Textbox();
void Initialize(std::string text,vf2d pos,std::string headerText="",vf2d maxSize={120,64},std::vector<Memory>resourceCost={},float letterDisplayDelay=0.01);
void Initialize(std::string text,vf2d pos={},std::string headerText="",vf2d maxSize={120,1},std::vector<Memory>resourceCost={},float letterDisplayDelay=0.01);
void UpdateAndDraw(vf2d pos,PixelGameEngine*pge,Resources&resources);
std::string&GetCurrentString();

@ -62,6 +62,7 @@ bool VirusAttack::OnUserCreate(){
{});
unitCreationBox.SetVisible(false);
testBox.Initialize("Hello world, this is a test of the textbox system.\nMaybe even with some newline characters snuck in there.",{});
testBox.SetVisible(false);
IMAGES[MINIMAP_OUTLINE]=std::make_unique<Renderable>();
IMAGES[MINIMAP_OUTLINE]->Create(64,64);

Loading…
Cancel
Save