diff --git a/olcCodeJam2023Entry/Info.txt b/olcCodeJam2023Entry/Info.txt index 6b1959f..7691539 100644 --- a/olcCodeJam2023Entry/Info.txt +++ b/olcCodeJam2023Entry/Info.txt @@ -56,3 +56,16 @@ Stage 2 Stage 3 Stage 4 Stage 5 - Hacking a Network + + +Potential Songs: +1 Pixel + +Space - Cosmos (Tutorials?) + +Space - Gravity (Ambient 1) +1 Epic Boss Battles (Cut for loop) (Ambient 2) +3 Epic Boss Battles (Cut end for loop) (Ambient 3) + + +1 Glorious Venture (Ending theme?) \ No newline at end of file diff --git a/olcCodeJam2023Entry/Textbox.cpp b/olcCodeJam2023Entry/Textbox.cpp index f57bd7a..8c8d553 100644 --- a/olcCodeJam2023Entry/Textbox.cpp +++ b/olcCodeJam2023Entry/Textbox.cpp @@ -21,8 +21,12 @@ void Textbox::SetDefaults(){ textboxMarker=-1; lastWordMarker=-1; lastWord=""; + lastHeaderWordMarker=-1; + lastHeaderWord=""; displayText=""; + displayHeaderText=""; text=""; + headerText=""; } void Textbox::Update(PixelGameEngine*pge){ @@ -31,21 +35,32 @@ void Textbox::Update(PixelGameEngine*pge){ if(textboxMarkerGetTextSizeProp(tempText).x>=maxSize.x){ - displayText=displayText.substr(0,lastWordMarker); - displayText+='\n'; - displayText+=lastWord; - } - if(text[textboxMarker+1]==' '||text[textboxMarker+1]=='\n'){ - lastWord=""; - lastWordMarker=textboxMarker+2; - } else { - lastWord+=text[textboxMarker+1]; + + auto WrapText=[&](std::string&tempText,std::string&text,std::string&displayText,int&lastWordMarker,std::string&lastWord){ + if(pge->GetTextSizeProp(tempText).x>=maxSize.x){ + displayText=displayText.substr(0,lastWordMarker); + displayText+='\n'; + displayText+=lastWord; + } + if(text[textboxMarker+1]==' '||text[textboxMarker+1]=='\n'){ + lastWord=""; + lastWordMarker=textboxMarker+2; + } else { + lastWord+=text[textboxMarker+1]; + } + displayText+=text[textboxMarker+1]; + }; + + WrapText(tempText,text,displayText,lastWordMarker,lastWord); + + if(textboxMarkerGetTextSizeProp(tempText).y)); } + maxSize.y=std::max(maxSize.y,float(pge->GetTextSizeProp(displayHeaderText).y+pge->GetTextSizeProp(displayText).y)); lastLetterTime=letterDisplayDelay; } } @@ -68,7 +83,8 @@ void Textbox::Draw(PixelGameEngine*pge,Resources&resources){ } 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}); + 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}); } } diff --git a/olcCodeJam2023Entry/Textbox.h b/olcCodeJam2023Entry/Textbox.h index acf7608..e1c3165 100644 --- a/olcCodeJam2023Entry/Textbox.h +++ b/olcCodeJam2023Entry/Textbox.h @@ -6,6 +6,7 @@ class Textbox{ std::string headerText=""; //If a textbox has a header, it displays at the top in a special color. + std::string displayHeaderText=""; std::string text=""; std::string displayText=""; vf2d pos={}; @@ -15,6 +16,8 @@ class Textbox{ int textboxMarker=-1; int lastWordMarker=-1; std::string lastWord=""; + int lastHeaderWordMarker=-1; + std::string lastHeaderWord=""; std::vector resourceCost; //If resource cost is greater than 0, shows them. bool visible=true; public: