|
|
|
@ -1191,6 +1191,32 @@ namespace olc |
|
|
|
|
int32_t TextEntryGetCursor() const; |
|
|
|
|
bool IsTextEntryEnabled() const; |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
static std::map<char,Pixel> charToColor; |
|
|
|
|
static std::string Grey; |
|
|
|
|
static std::string Dark_Grey; |
|
|
|
|
static std::string Very_Dark_Grey; |
|
|
|
|
static std::string Red; |
|
|
|
|
static std::string Dark_Red; |
|
|
|
|
static std::string Very_Dark_Red; |
|
|
|
|
static std::string Yellow; |
|
|
|
|
static std::string Dark_Yellow; |
|
|
|
|
static std::string Very_Dark_Yellow; |
|
|
|
|
static std::string Green; |
|
|
|
|
static std::string Dark_Green; |
|
|
|
|
static std::string Very_Dark_Green; |
|
|
|
|
static std::string Cyan; |
|
|
|
|
static std::string Dark_Cyan; |
|
|
|
|
static std::string Very_Dark_Cyan; |
|
|
|
|
static std::string Blue; |
|
|
|
|
static std::string Dark_Blue; |
|
|
|
|
static std::string Very_Dark_Blue; |
|
|
|
|
static std::string Magenta; |
|
|
|
|
static std::string Dark_Magenta; |
|
|
|
|
static std::string Very_Dark_Magenta; |
|
|
|
|
static std::string White; |
|
|
|
|
static std::string Black; |
|
|
|
|
static std::string Reset; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
@ -1479,6 +1505,31 @@ namespace olc |
|
|
|
|
#pragma region pge_implementation |
|
|
|
|
namespace olc |
|
|
|
|
{ |
|
|
|
|
std::map<char,Pixel> PixelGameEngine::charToColor; |
|
|
|
|
std::string PixelGameEngine::Grey; |
|
|
|
|
std::string PixelGameEngine::Dark_Grey; |
|
|
|
|
std::string PixelGameEngine::Very_Dark_Grey; |
|
|
|
|
std::string PixelGameEngine::Red; |
|
|
|
|
std::string PixelGameEngine::Dark_Red; |
|
|
|
|
std::string PixelGameEngine::Very_Dark_Red; |
|
|
|
|
std::string PixelGameEngine::Yellow; |
|
|
|
|
std::string PixelGameEngine::Dark_Yellow; |
|
|
|
|
std::string PixelGameEngine::Very_Dark_Yellow; |
|
|
|
|
std::string PixelGameEngine::Green; |
|
|
|
|
std::string PixelGameEngine::Dark_Green; |
|
|
|
|
std::string PixelGameEngine::Very_Dark_Green; |
|
|
|
|
std::string PixelGameEngine::Cyan; |
|
|
|
|
std::string PixelGameEngine::Dark_Cyan; |
|
|
|
|
std::string PixelGameEngine::Very_Dark_Cyan; |
|
|
|
|
std::string PixelGameEngine::Blue; |
|
|
|
|
std::string PixelGameEngine::Dark_Blue; |
|
|
|
|
std::string PixelGameEngine::Very_Dark_Blue; |
|
|
|
|
std::string PixelGameEngine::Magenta; |
|
|
|
|
std::string PixelGameEngine::Dark_Magenta; |
|
|
|
|
std::string PixelGameEngine::Very_Dark_Magenta; |
|
|
|
|
std::string PixelGameEngine::White; |
|
|
|
|
std::string PixelGameEngine::Black; |
|
|
|
|
std::string PixelGameEngine::Reset; //Will render the original color provided when used.
|
|
|
|
|
// O------------------------------------------------------------------------------O
|
|
|
|
|
// | olc::Pixel IMPLEMENTATION |
|
|
|
|
|
// O------------------------------------------------------------------------------O
|
|
|
|
@ -3288,6 +3339,7 @@ namespace olc |
|
|
|
|
void PixelGameEngine::DrawStringDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col, const olc::vf2d& scale) |
|
|
|
|
{ |
|
|
|
|
olc::vf2d spos = { 0.0f, 0.0f }; |
|
|
|
|
Pixel textCol=col; |
|
|
|
|
for (auto c : sText) |
|
|
|
|
{ |
|
|
|
|
if(c=='\r')continue; //Ignore carriage returns. Stupid Linux.
|
|
|
|
@ -3299,11 +3351,19 @@ namespace olc |
|
|
|
|
{ |
|
|
|
|
spos.x += 8.0f * float(nTabSizeInSpaces) * scale.x; |
|
|
|
|
} |
|
|
|
|
else if (c>=-128&&c<-105) |
|
|
|
|
{ |
|
|
|
|
textCol={charToColor[c].r,charToColor[c].g,charToColor[c].b,col.a}; |
|
|
|
|
} |
|
|
|
|
else if (c==Reset[0]) |
|
|
|
|
{ |
|
|
|
|
textCol=col; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
int32_t ox = (c - 32) % 16; |
|
|
|
|
int32_t oy = (c - 32) / 16; |
|
|
|
|
DrawPartialDecal(pos + spos, fontRenderable.Decal(), {float(ox) * 8.0f, float(oy) * 8.0f}, {8.0f, 8.0f}, scale, col); |
|
|
|
|
DrawPartialDecal(pos + spos, fontRenderable.Decal(), {float(ox) * 8.0f, float(oy) * 8.0f}, {8.0f, 8.0f}, scale, textCol); |
|
|
|
|
spos.x += 8.0f * scale.x; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -3312,6 +3372,7 @@ namespace olc |
|
|
|
|
void PixelGameEngine::DrawStringPropDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col, const olc::vf2d& scale) |
|
|
|
|
{ |
|
|
|
|
olc::vf2d spos = { 0.0f, 0.0f }; |
|
|
|
|
Pixel textCol=col; |
|
|
|
|
for (auto c : sText) |
|
|
|
|
{ |
|
|
|
|
if(c=='\r')continue; //Ignore carriage returns. Stupid Linux.
|
|
|
|
@ -3323,21 +3384,31 @@ namespace olc |
|
|
|
|
{ |
|
|
|
|
spos.x += 8.0f * float(nTabSizeInSpaces) * scale.x; |
|
|
|
|
} |
|
|
|
|
else if (c>=-128&&c<-105) |
|
|
|
|
{ |
|
|
|
|
textCol={charToColor[c].r,charToColor[c].g,charToColor[c].b,col.a}; |
|
|
|
|
} |
|
|
|
|
else if (c==Reset[0]) |
|
|
|
|
{ |
|
|
|
|
textCol=col; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
int32_t ox = (c - 32) % 16; |
|
|
|
|
int32_t oy = (c - 32) / 16; |
|
|
|
|
DrawPartialDecal(pos + spos, fontRenderable.Decal(), { float(ox) * 8.0f + float(vFontSpacing[c - 32].x), float(oy) * 8.0f }, { float(vFontSpacing[c - 32].y), 8.0f }, scale, col); |
|
|
|
|
DrawPartialDecal(pos + spos, fontRenderable.Decal(), { float(ox) * 8.0f + float(vFontSpacing[c - 32].x), float(oy) * 8.0f }, { float(vFontSpacing[c - 32].y), 8.0f }, scale, textCol); |
|
|
|
|
spos.x += float(vFontSpacing[c - 32].y) * scale.x; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawShadowStringDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float shadowSizeFactor){ |
|
|
|
|
std::string strippedText=sText; |
|
|
|
|
std::erase_if(strippedText,[](char chr){return chr<0;}); |
|
|
|
|
for(float y=-shadowSizeFactor;y<=shadowSizeFactor+0.1;y+=shadowSizeFactor/2){ |
|
|
|
|
for(float x=-shadowSizeFactor;x<=shadowSizeFactor+0.1;x+=shadowSizeFactor/2){ |
|
|
|
|
if(x!=0||y!=0){ |
|
|
|
|
DrawStringDecal(pos+vf2d{x,y}, sText, shadowCol,scale); |
|
|
|
|
DrawStringDecal(pos+vf2d{x,y}, strippedText, shadowCol,scale); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -3421,10 +3492,12 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawShadowStringPropDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float shadowSizeFactor){ |
|
|
|
|
std::string strippedText=sText; |
|
|
|
|
std::erase_if(strippedText,[](char chr){return chr<0;}); |
|
|
|
|
for(float y=-shadowSizeFactor;y<=shadowSizeFactor+0.1;y+=shadowSizeFactor/2){ |
|
|
|
|
for(float x=-shadowSizeFactor;x<=shadowSizeFactor+0.1;x+=shadowSizeFactor/2){ |
|
|
|
|
if(x!=0||y!=0){ |
|
|
|
|
DrawStringPropDecal(pos+vf2d{x,y}, sText, shadowCol,scale); |
|
|
|
|
DrawStringPropDecal(pos+vf2d{x,y}, strippedText, shadowCol,scale); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -3432,10 +3505,12 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawShadowString(const olc::vi2d& pos, const std::string& sText, Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float shadowSizeFactor){ |
|
|
|
|
std::string strippedText=sText; |
|
|
|
|
std::erase_if(strippedText,[](char chr){return chr<0;}); |
|
|
|
|
for(float y=-shadowSizeFactor;y<=shadowSizeFactor+0.1;y+=shadowSizeFactor/2){ |
|
|
|
|
for(float x=-shadowSizeFactor;x<=shadowSizeFactor+0.1;x+=shadowSizeFactor/2){ |
|
|
|
|
if(x!=0||y!=0){ |
|
|
|
|
DrawString(int32_t(pos.x+x),int32_t(pos.y+y), sText, shadowCol,int(scale.x)); |
|
|
|
|
DrawString(int32_t(pos.x+x),int32_t(pos.y+y), strippedText, shadowCol,int(scale.x)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -3443,10 +3518,12 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawShadowStringProp(const olc::vi2d& pos, const std::string& sText, Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float shadowSizeFactor){ |
|
|
|
|
std::string strippedText=sText; |
|
|
|
|
std::erase_if(strippedText,[](char chr){return chr<0;}); |
|
|
|
|
for(float y=-shadowSizeFactor;y<=shadowSizeFactor+0.1;y+=shadowSizeFactor/2){ |
|
|
|
|
for(float x=-shadowSizeFactor;x<=shadowSizeFactor+0.1;x+=shadowSizeFactor/2){ |
|
|
|
|
if(x!=0||y!=0){ |
|
|
|
|
DrawStringProp(int32_t(pos.x+x),int32_t(pos.y+y), sText, shadowCol,int(scale.x)); |
|
|
|
|
DrawStringProp(int32_t(pos.x+x),int32_t(pos.y+y), strippedText, shadowCol,int(scale.x)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -3545,6 +3622,7 @@ namespace olc |
|
|
|
|
int32_t sx = 0; |
|
|
|
|
int32_t sy = 0; |
|
|
|
|
Pixel::Mode m = nPixelMode; |
|
|
|
|
Pixel textCol=col; |
|
|
|
|
// Thanks @tucna, spotted bug with col.ALPHA :P
|
|
|
|
|
if (m != Pixel::CUSTOM) // Thanks @Megarev, required for "shaders"
|
|
|
|
|
{ |
|
|
|
@ -3562,6 +3640,14 @@ namespace olc |
|
|
|
|
{ |
|
|
|
|
sx += 8 * nTabSizeInSpaces * scale; |
|
|
|
|
} |
|
|
|
|
else if (c>=-128&&c<-105) |
|
|
|
|
{ |
|
|
|
|
textCol={charToColor[c].r,charToColor[c].g,charToColor[c].b,col.a}; |
|
|
|
|
} |
|
|
|
|
else if (c==Reset[0]) |
|
|
|
|
{ |
|
|
|
|
textCol=col; |
|
|
|
|
} |
|
|
|
|
else
|
|
|
|
|
{ |
|
|
|
|
int32_t ox = (c - 32) % 16; |
|
|
|
@ -3574,14 +3660,14 @@ namespace olc |
|
|
|
|
if (fontRenderable.Sprite()->GetPixel(i + ox * 8, j + oy * 8).r > 0) |
|
|
|
|
for (uint32_t is = 0; is < scale; is++) |
|
|
|
|
for (uint32_t js = 0; js < scale; js++) |
|
|
|
|
Draw(x + sx + (i * scale) + is, y + sy + (j * scale) + js, col); |
|
|
|
|
Draw(x + sx + (i * scale) + is, y + sy + (j * scale) + js, textCol); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
for (uint32_t i = 0; i < 8; i++) |
|
|
|
|
for (uint32_t j = 0; j < 8; j++) |
|
|
|
|
if (fontRenderable.Sprite()->GetPixel(i + ox * 8, j + oy * 8).r > 0) |
|
|
|
|
Draw(x + sx + i, y + sy + j, col); |
|
|
|
|
Draw(x + sx + i, y + sy + j, textCol); |
|
|
|
|
} |
|
|
|
|
sx += 8 * scale; |
|
|
|
|
} |
|
|
|
@ -3615,7 +3701,7 @@ namespace olc |
|
|
|
|
int32_t sx = 0; |
|
|
|
|
int32_t sy = 0; |
|
|
|
|
Pixel::Mode m = nPixelMode; |
|
|
|
|
|
|
|
|
|
Pixel textCol=col; |
|
|
|
|
if (m != Pixel::CUSTOM) |
|
|
|
|
{ |
|
|
|
|
if (col.a != 255) SetPixelMode(Pixel::ALPHA); |
|
|
|
@ -3632,6 +3718,14 @@ namespace olc |
|
|
|
|
{ |
|
|
|
|
sx += 8 * nTabSizeInSpaces * scale; |
|
|
|
|
} |
|
|
|
|
else if (c>=-128&&c<-105) |
|
|
|
|
{ |
|
|
|
|
textCol={charToColor[c].r,charToColor[c].g,charToColor[c].b,col.a}; |
|
|
|
|
} |
|
|
|
|
else if (c==Reset[0]) |
|
|
|
|
{ |
|
|
|
|
textCol=col; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
int32_t ox = (c - 32) % 16; |
|
|
|
@ -3644,14 +3738,14 @@ namespace olc |
|
|
|
|
if (fontRenderable.Sprite()->GetPixel(i + ox * 8 + vFontSpacing[c - 32].x, j + oy * 8).r > 0) |
|
|
|
|
for (int32_t is = 0; is < int(scale); is++) |
|
|
|
|
for (int32_t js = 0; js < int(scale); js++) |
|
|
|
|
Draw(x + sx + (i * scale) + is, y + sy + (j * scale) + js, col); |
|
|
|
|
Draw(x + sx + (i * scale) + is, y + sy + (j * scale) + js, textCol); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
for (int32_t i = 0; i < vFontSpacing[c - 32].y; i++) |
|
|
|
|
for (int32_t j = 0; j < 8; j++) |
|
|
|
|
if (fontRenderable.Sprite()->GetPixel(i + ox * 8 + vFontSpacing[c - 32].x, j + oy * 8).r > 0) |
|
|
|
|
Draw(x + sx + i, y + sy + j, col); |
|
|
|
|
Draw(x + sx + i, y + sy + j, textCol); |
|
|
|
|
} |
|
|
|
|
sx += vFontSpacing[c - 32].y * scale; |
|
|
|
|
} |
|
|
|
@ -4021,6 +4115,55 @@ namespace olc |
|
|
|
|
// Start OpenGL, the context is owned by the game thread
|
|
|
|
|
if (platform->CreateGraphics(bFullScreen, bEnableVSYNC, vViewPos, vViewSize) == olc::FAIL) return; |
|
|
|
|
|
|
|
|
|
charToColor[-128]=GREY; |
|
|
|
|
charToColor[-127]=DARK_GREY; |
|
|
|
|
charToColor[-126]=VERY_DARK_GREY; |
|
|
|
|
charToColor[-125]=RED; |
|
|
|
|
charToColor[-124]=DARK_RED; |
|
|
|
|
charToColor[-123]=VERY_DARK_RED; |
|
|
|
|
charToColor[-122]=YELLOW; |
|
|
|
|
charToColor[-121]=DARK_YELLOW; |
|
|
|
|
charToColor[-120]=VERY_DARK_YELLOW; |
|
|
|
|
charToColor[-119]=GREEN; |
|
|
|
|
charToColor[-118]=DARK_GREEN; |
|
|
|
|
charToColor[-117]=VERY_DARK_GREEN; |
|
|
|
|
charToColor[-116]=CYAN; |
|
|
|
|
charToColor[-115]=DARK_CYAN; |
|
|
|
|
charToColor[-114]=VERY_DARK_CYAN; |
|
|
|
|
charToColor[-113]=BLUE; |
|
|
|
|
charToColor[-112]=DARK_BLUE; |
|
|
|
|
charToColor[-111]=VERY_DARK_BLUE; |
|
|
|
|
charToColor[-110]=MAGENTA; |
|
|
|
|
charToColor[-109]=DARK_MAGENTA; |
|
|
|
|
charToColor[-108]=VERY_DARK_MAGENTA; |
|
|
|
|
charToColor[-107]=WHITE; |
|
|
|
|
charToColor[-106]=BLACK; |
|
|
|
|
|
|
|
|
|
Grey =std::string(1,char(-128)); |
|
|
|
|
Dark_Grey =std::string(1,char(-127)); |
|
|
|
|
Very_Dark_Grey =std::string(1,char(-126)); |
|
|
|
|
Red =std::string(1,char(-125)); |
|
|
|
|
Dark_Red =std::string(1,char(-124)); |
|
|
|
|
Very_Dark_Red =std::string(1,char(-123)); |
|
|
|
|
Yellow =std::string(1,char(-122)); |
|
|
|
|
Dark_Yellow =std::string(1,char(-121)); |
|
|
|
|
Very_Dark_Yellow =std::string(1,char(-120)); |
|
|
|
|
Green =std::string(1,char(-119)); |
|
|
|
|
Dark_Green =std::string(1,char(-118)); |
|
|
|
|
Very_Dark_Green =std::string(1,char(-117)); |
|
|
|
|
Cyan =std::string(1,char(-116)); |
|
|
|
|
Dark_Cyan =std::string(1,char(-115)); |
|
|
|
|
Very_Dark_Cyan =std::string(1,char(-114)); |
|
|
|
|
Blue =std::string(1,char(-113)); |
|
|
|
|
Dark_Blue =std::string(1,char(-112)); |
|
|
|
|
Very_Dark_Blue =std::string(1,char(-111)); |
|
|
|
|
Magenta =std::string(1,char(-110)); |
|
|
|
|
Dark_Magenta =std::string(1,char(-109)); |
|
|
|
|
Very_Dark_Magenta =std::string(1,char(-108)); |
|
|
|
|
White =std::string(1,char(-107)); |
|
|
|
|
Black =std::string(1,char(-106)); |
|
|
|
|
Reset =std::string(1,char(-105)); |
|
|
|
|
|
|
|
|
|
// Construct default font sheet
|
|
|
|
|
olc_ConstructFontSheet(); |
|
|
|
|
|
|
|
|
@ -6954,4 +7097,6 @@ namespace olc |
|
|
|
|
|
|
|
|
|
using namespace olc; |
|
|
|
|
|
|
|
|
|
#define PI 3.14159f |
|
|
|
|
#define PI 3.14159f |
|
|
|
|
|
|
|
|
|
using Color=PixelGameEngine; |