Fix some deprecation warnings

Namely:

 - [[deprecated("Use BlendTextOutline")]]
 - [[deprecated("Use BlendText")]]
 - [[deprecated("Use BlendImage")]]
 - [[deprecated("Use BlendImage")]]
 - [[deprecated("Use TextSize().X - 1 (yes this is very bad code eww)")]]
This commit is contained in:
Tamás Bálint Misius 2023-04-29 15:34:19 +02:00
parent 2960e0f58f
commit f5cbc30d85
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
35 changed files with 103 additions and 168 deletions

View File

@ -440,7 +440,7 @@ int main(int argc, char * argv[])
engine.g->Clear(); engine.g->Clear();
engine.g->DrawRect(RectSized(engine.g->Size() / 2 - Vec2(100, 25), Vec2(200, 50)), 0xB4B4B4_rgb); engine.g->DrawRect(RectSized(engine.g->Size() / 2 - Vec2(100, 25), Vec2(200, 50)), 0xB4B4B4_rgb);
String loadingText = "Loading save..."; String loadingText = "Loading save...";
engine.g->BlendText(engine.g->Size() / 2 - Vec2(Graphics::textwidth(loadingText) / 2, 5), loadingText, style::Colour::InformationTitle); engine.g->BlendText(engine.g->Size() / 2 - Vec2((Graphics::TextSize(loadingText).X - 1) / 2, 5), loadingText, style::Colour::InformationTitle);
blit(engine.g->Data()); blit(engine.g->Data());
try try

View File

@ -61,9 +61,9 @@ int main(int argc, char *argv[])
} }
else else
{ {
int w = Graphics::textwidth("Save file invalid")+16, x = (XRES-w)/2, y = (YRES-24)/2; int w = Graphics::TextSize("Save file invalid").X + 15, x = (XRES-w)/2, y = (YRES-24)/2;
ren->drawrect(x, y, w, 24, 192, 192, 192, 255); ren->drawrect(x, y, w, 24, 192, 192, 192, 255);
ren->drawtext(x+8, y+8, "Save file invalid", 192, 192, 240, 255); ren->BlendText({ x+8, y+8 }, "Save file invalid", RGBA<uint8_t>(192, 192, 240, 255));
} }
ren->RenderBegin(); ren->RenderBegin();

View File

@ -31,16 +31,16 @@ void DebugLines::Draw()
String info; String info;
info = String::Build(drawPoint2.X, " x ", drawPoint2.Y); info = String::Build(drawPoint2.X, " x ", drawPoint2.Y);
g->drawtext_outline(drawPoint2.X+(drawPoint2.X>drawPoint1.X?3:-g->textwidth(info)-3), drawPoint2.Y+(drawPoint2.Y<drawPoint1.Y?-10:3), info, 255, 255, 255, 200); g->BlendTextOutline({ drawPoint2.X+(drawPoint2.X>drawPoint1.X?3:-(g->TextSize(info).X-1)-3), drawPoint2.Y+(drawPoint2.Y<drawPoint1.Y?-10:3) }, info, RGBA<uint8_t>(255, 255, 255, 200));
info = String::Build(drawPoint1.X, " x ", drawPoint1.Y); info = String::Build(drawPoint1.X, " x ", drawPoint1.Y);
g->drawtext_outline(drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-g->textwidth(info)-2), drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info, 255, 255, 255, 200); g->BlendTextOutline({ drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-(g->TextSize(info).X-1)-2), drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3) }, info, RGBA<uint8_t>(255, 255, 255, 200));
info = String::Build(std::abs(drawPoint2.X-drawPoint1.X)); info = String::Build(std::abs(drawPoint2.X-drawPoint1.X));
g->drawtext_outline((drawPoint1.X+drawPoint2.X)/2-g->textwidth(info)/2, drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info, 255, 255, 255, 200); g->BlendTextOutline({ (drawPoint1.X+drawPoint2.X)/2-(g->TextSize(info).X-1)/2, drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3) }, info, RGBA<uint8_t>(255, 255, 255, 200));
info = String::Build(std::abs(drawPoint2.Y-drawPoint1.Y)); info = String::Build(std::abs(drawPoint2.Y-drawPoint1.Y));
g->drawtext_outline(drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-g->textwidth(info)-2), (drawPoint1.Y+drawPoint2.Y)/2-3, info, 255, 255, 255, 200); g->BlendTextOutline({ drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-(g->TextSize(info).X-1)-2), (drawPoint1.Y+drawPoint2.Y)/2-3 }, info, RGBA<uint8_t>(255, 255, 255, 200));
} }
} }

View File

@ -47,8 +47,8 @@ void DebugParts::Draw()
g->addpixel(lpx, lpy+1, 255, 50, 50, 120); g->addpixel(lpx, lpy+1, 255, 50, 50, 120);
g->addpixel(lpx, lpy-1, 255, 50, 50, 120); g->addpixel(lpx, lpy-1, 255, 50, 50, 120);
g->fillrect(7, YRES-26, g->textwidth(info)+5, 14, 0, 0, 0, 180); g->fillrect(7, YRES-26, g->TextSize(info).X + 4, 14, 0, 0, 0, 180);
g->drawtext(10, YRES-22, info, 255, 255, 255, 255); g->BlendText({ 10, YRES-22 }, info, RGBA<uint8_t>(255, 255, 255, 255));
} }
DebugParts::~DebugParts() DebugParts::~DebugParts()

View File

@ -44,7 +44,7 @@ void ElementPopulationDebug::Draw()
halfValString = String::Build(maxAverage/2); halfValString = String::Build(maxAverage/2);
g->fillrect(xStart-5, yBottom - 263, bars+10+Graphics::textwidth(maxValString)+10, 255 + 13, 0, 0, 0, 180); g->fillrect(xStart-5, yBottom - 263, bars+10+Graphics::TextSize(maxValString).X+9, 255 + 13, 0, 0, 0, 180);
bars = 0; bars = 0;
for(int i = 0; i < PT_NUM; i++) for(int i = 0; i < PT_NUM; i++)
@ -76,9 +76,9 @@ void ElementPopulationDebug::Draw()
} }
} }
g->drawtext(xStart + bars + 5, yBottom-5, "0", 255, 255, 255, 255); g->BlendText({ xStart + bars + 5, yBottom-5 }, "0", RGBA<uint8_t>(255, 255, 255, 255));
g->drawtext(xStart + bars + 5, yBottom-132, halfValString, 255, 255, 255, 255); g->BlendText({ xStart + bars + 5, yBottom-132 }, halfValString, RGBA<uint8_t>(255, 255, 255, 255));
g->drawtext(xStart + bars + 5, yBottom-260, maxValString, 255, 255, 255, 255); g->BlendText({ xStart + bars + 5, yBottom-260 }, maxValString, RGBA<uint8_t>(255, 255, 255, 255));
} }
ElementPopulationDebug::~ElementPopulationDebug() ElementPopulationDebug::~ElementPopulationDebug()

View File

@ -167,11 +167,6 @@ template class RasterDrawMethods<VideoBuffer>;
Graphics::Graphics() Graphics::Graphics()
{} {}
int Graphics::textwidth(const String &str)
{
return TextSize(str).X - 1;
}
void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool invert) void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool invert)
{ {
y--; y--;
@ -199,12 +194,12 @@ void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool inve
if(invert) if(invert)
{ {
drawchar(x-11, y+1, 0xE04B, 0, 100, 0, alpha); drawchar(x-11, y+1, 0xE04B, 0, 100, 0, alpha);
drawtext(x+2, y+1, "Vote", 0, 100, 0, alpha); BlendText({ x+2, y+1 }, "Vote", RGBA<uint8_t>(0, 100, 0, alpha));
} }
else else
{ {
drawchar(x-11, y+1, 0xE04B, 0, 187, 18, alpha); drawchar(x-11, y+1, 0xE04B, 0, 187, 18, alpha);
drawtext(x+2, y+1, "Vote", 0, 187, 18, alpha); BlendText({ x+2, y+1 }, "Vote", RGBA<uint8_t>(0, 187, 18, alpha));
} }
break; break;
case IconVoteDown: case IconVoteDown:

View File

@ -91,10 +91,6 @@ public:
}; };
static std::vector<RGB<uint8_t>> Gradient(std::vector<GradientStop> stops, int resolution); static std::vector<RGB<uint8_t>> Gradient(std::vector<GradientStop> stops, int resolution);
//Font/text metrics
[[deprecated("Use TextSize().X - 1 (yes this is very bad code eww)")]]
static int textwidth(const String &s);
VideoBuffer DumpFrame(); VideoBuffer DumpFrame();
void draw_icon(int x, int y, Icon icon, unsigned char alpha = 255, bool invert = false); void draw_icon(int x, int y, Icon icon, unsigned char alpha = 255, bool invert = false);

View File

@ -60,10 +60,6 @@ struct RasterDrawMethods
void Clear(); void Clear();
[[deprecated("Use BlendTextOutline")]]
int drawtext_outline(int x, int y, const String &, int r, int g, int b, int a);
[[deprecated("Use BlendText")]]
int drawtext(int x, int y, const String &, int r, int g, int b, int a);
[[deprecated("Use BlendChar")]] [[deprecated("Use BlendChar")]]
int drawchar(int x, int y, String::value_type, int r, int g, int b, int a); int drawchar(int x, int y, String::value_type, int r, int g, int b, int a);
[[deprecated("Use AddChar")]] [[deprecated("Use AddChar")]]
@ -92,8 +88,4 @@ struct RasterDrawMethods
void fillcircle(int x, int y, int rx, int ry, int r, int g, int b, int a); void fillcircle(int x, int y, int rx, int ry, int r, int g, int b, int a);
[[deprecated("Use DrawFilledRect (beware off by 1)")]] [[deprecated("Use DrawFilledRect (beware off by 1)")]]
void clearrect(int x, int y, int w, int h); void clearrect(int x, int y, int w, int h);
[[deprecated("Use BlendImage")]]
void draw_image(pixel const *, int x, int y, int w, int h, int a);
[[deprecated("Use BlendImage")]]
void draw_image(VideoBuffer const *, int x, int y, int a);
}; };

View File

@ -401,18 +401,6 @@ String::const_iterator RasterDrawMethods<Derived>::TextFit(String const &str, in
return str.end(); return str.end();
} }
template<typename Derived>
int RasterDrawMethods<Derived>::drawtext_outline(int x, int y, const String &s, int r, int g, int b, int a)
{
return x + BlendTextOutline(Vec2(x, y), s, RGBA<uint8_t>(r, g, b, a)).X;
}
template<typename Derived>
int RasterDrawMethods<Derived>::drawtext(int x, int y, const String &str, int r, int g, int b, int a)
{
return x + BlendText(Vec2(x, y), str, RGBA<uint8_t>(r, g, b, a)).X;
}
template<typename Derived> template<typename Derived>
int RasterDrawMethods<Derived>::drawchar(int x, int y, String::value_type c, int r, int g, int b, int a) int RasterDrawMethods<Derived>::drawchar(int x, int y, String::value_type c, int r, int g, int b, int a)
{ {
@ -513,17 +501,5 @@ void RasterDrawMethods<Derived>::clearrect(int x, int y, int w, int h)
DrawFilledRect(RectSized(Vec2(x + 1, y + 1), Vec2(w - 1, h - 1)), 0x000000_rgb); DrawFilledRect(RectSized(Vec2(x + 1, y + 1), Vec2(w - 1, h - 1)), 0x000000_rgb);
} }
template<typename Derived>
void RasterDrawMethods<Derived>::draw_image(const pixel *img, int x, int y, int w, int h, int a)
{
BlendImage(img, a, RectSized(Vec2(x, y), Vec2(w, h)));
}
template<typename Derived>
void RasterDrawMethods<Derived>::draw_image(const VideoBuffer * vidBuf, int x, int y, int a)
{
BlendImage(vidBuf->Data(), a, RectSized(Vec2(x, y), vidBuf->Size()));
}
#undef video #undef video
#undef clipRect #undef clipRect

View File

@ -152,7 +152,7 @@ void Renderer::DrawSigns()
String text = currentSign.getDisplayText(sim, x, y, w, h); String text = currentSign.getDisplayText(sim, x, y, w, h);
clearrect(x, y, w+1, h); clearrect(x, y, w+1, h);
drawrect(x, y, w+1, h, 192, 192, 192, 255); drawrect(x, y, w+1, h, 192, 192, 192, 255);
drawtext(x+3, y+4, text, 255, 255, 255, 255); BlendText({ x+3, y+4 }, text, RGBA<uint8_t>(255, 255, 255, 255));
if (currentSign.ju != sign::None) if (currentSign.ju != sign::None)
{ {
@ -417,7 +417,7 @@ void Renderer::render_parts()
if (mousePos.X>(nx-3) && mousePos.X<(nx+3) && mousePos.Y<(ny+3) && mousePos.Y>(ny-3)) //If mouse is in the head if (mousePos.X>(nx-3) && mousePos.X<(nx+3) && mousePos.Y<(ny+3) && mousePos.Y>(ny-3)) //If mouse is in the head
{ {
String hp = String::Build(Format::Width(sim->parts[i].life, 3)); String hp = String::Build(Format::Width(sim->parts[i].life, 3));
drawtext(mousePos.X-8-2*(sim->parts[i].life<100)-2*(sim->parts[i].life<10), mousePos.Y-12, hp, 255, 255, 255, 255); BlendText(mousePos + Vec2{ -8-2*(sim->parts[i].life<100)-2*(sim->parts[i].life<10), -12 }, hp, RGBA<uint8_t>(255, 255, 255, 255));
} }
if (findingElement == t) if (findingElement == t)
@ -980,7 +980,7 @@ void Renderer::DrawWalls()
// there is no velocity here, draw a streamline and continue // there is no velocity here, draw a streamline and continue
if (!xVel && !yVel) if (!xVel && !yVel)
{ {
drawtext(x*CELL, y*CELL-2, 0xE00D, 255, 255, 255, 128); BlendText({ x*CELL, y*CELL-2 }, 0xE00D, RGBA<uint8_t>(255, 255, 255, 128));
addpixel(oldX, oldY, 255, 255, 255, 255); addpixel(oldX, oldY, 255, 255, 255, 255);
continue; continue;
} }
@ -1011,7 +1011,7 @@ void Renderer::DrawWalls()
xf += xVel; xf += xVel;
yf += yVel; yf += yVel;
} }
drawtext(x*CELL, y*CELL-2, 0xE00D, 255, 255, 255, 128); BlendText({ x*CELL, y*CELL-2 }, 0xE00D, RGBA<uint8_t>(255, 255, 255, 128));
} }
break; break;
case 1: case 1:

View File

@ -10,26 +10,26 @@
SaveIDMessage::SaveIDMessage(int id): SaveIDMessage::SaveIDMessage(int id):
ui::Window(ui::Point((XRES-244)/2, (YRES-90)/2), ui::Point(244, 90)) ui::Window(ui::Point((XRES-244)/2, (YRES-90)/2), ui::Point(244, 90))
{ {
int textWidth = Graphics::textwidth("Save ID"); int textWidth = Graphics::TextSize("Save ID").X - 1;
ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(textWidth+20, 16), "Save ID"); ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(textWidth+20, 16), "Save ID");
titleLabel->SetTextColour(style::Colour::InformationTitle); titleLabel->SetTextColour(style::Colour::InformationTitle);
titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(titleLabel); AddComponent(titleLabel);
textWidth = Graphics::textwidth("Saved Successfully!"); textWidth = Graphics::TextSize("Saved Successfully!").X - 1;
ui::Label * messageLabel = new ui::Label(ui::Point(4, 24), ui::Point(textWidth+20, 16), "Saved Successfully!"); ui::Label * messageLabel = new ui::Label(ui::Point(4, 24), ui::Point(textWidth+20, 16), "Saved Successfully!");
messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop; messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
AddComponent(messageLabel); AddComponent(messageLabel);
textWidth = Graphics::textwidth("Click the box below to copy the save ID"); textWidth = Graphics::TextSize("Click the box below to copy the save ID").X - 1;
ui::Label * copyTextLabel = new ui::Label(ui::Point((Size.X-textWidth-20)/2, 35), ui::Point(textWidth+20, 16), "Click the box below to copy the save id"); ui::Label * copyTextLabel = new ui::Label(ui::Point((Size.X-textWidth-20)/2, 35), ui::Point(textWidth+20, 16), "Click the box below to copy the save id");
copyTextLabel->SetTextColour(ui::Colour(150, 150, 150)); copyTextLabel->SetTextColour(ui::Colour(150, 150, 150));
copyTextLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; copyTextLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
AddComponent(copyTextLabel); AddComponent(copyTextLabel);
textWidth = Graphics::textwidth(String::Build(id)); textWidth = Graphics::TextSize(String::Build(id)).X - 1;
ui::CopyTextButton * copyTextButton = new ui::CopyTextButton(ui::Point((Size.X-textWidth-10)/2, 50), ui::Point(textWidth+10, 18), String::Build(id), copyTextLabel); ui::CopyTextButton * copyTextButton = new ui::CopyTextButton(ui::Point((Size.X-textWidth-10)/2, 50), ui::Point(textWidth+10, 18), String::Build(id), copyTextLabel);
AddComponent(copyTextButton); AddComponent(copyTextButton);

View File

@ -218,7 +218,7 @@ void ElementSearchActivity::OnDraw()
g->drawrect(Position.X+searchField->Position.X, Position.Y+searchField->Position.Y+searchField->Size.Y+8, searchField->Size.X, Size.Y-(searchField->Position.Y+searchField->Size.Y+8)-23, 255, 255, 255, 180); g->drawrect(Position.X+searchField->Position.X, Position.Y+searchField->Position.Y+searchField->Size.Y+8, searchField->Size.X, Size.Y-(searchField->Position.Y+searchField->Size.Y+8)-23, 255, 255, 255, 180);
if (toolTipPresence && toolTip.length()) if (toolTipPresence && toolTip.length())
{ {
g->drawtext(10, Size.Y+70, toolTip, 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5); g->BlendText({ 10, Size.Y+70 }, toolTip, RGBA<uint8_t>(255, 255, 255, toolTipPresence>51?255:toolTipPresence*5));
} }
} }

View File

@ -503,7 +503,7 @@ void FontEditor::OnDraw()
} }
else else
{ {
g->drawtext(8, 8, "No character", 255, 0, 0, 255); g->BlendText({ 8, 8 }, "No character", RGBA<uint8_t>(255, 0, 0, 255));
} }
} }

View File

@ -1278,16 +1278,16 @@ void GameView::ToolTip(ui::Point senderPosition, String toolTip)
else if(senderPosition.X > Size.X-BARSIZE)// < Size.Y-(quickOptionButtons.size()+1)*16) else if(senderPosition.X > Size.X-BARSIZE)// < Size.Y-(quickOptionButtons.size()+1)*16)
{ {
this->toolTip = toolTip; this->toolTip = toolTip;
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth(toolTip), senderPosition.Y+3); toolTipPosition = ui::Point(Size.X-27-(Graphics::TextSize(toolTip).X - 1), senderPosition.Y+3);
if(toolTipPosition.Y+10 > Size.Y-MENUSIZE) if(toolTipPosition.Y+10 > Size.Y-MENUSIZE)
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth(toolTip), Size.Y-MENUSIZE-10); toolTipPosition = ui::Point(Size.X-27-(Graphics::TextSize(toolTip).X - 1), Size.Y-MENUSIZE-10);
isToolTipFadingIn = true; isToolTipFadingIn = true;
} }
// element tooltips // element tooltips
else else
{ {
this->toolTip = toolTip; this->toolTip = toolTip;
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth(toolTip), Size.Y-MENUSIZE-10); toolTipPosition = ui::Point(Size.X-27-(Graphics::TextSize(toolTip).X - 1), Size.Y-MENUSIZE-10);
isToolTipFadingIn = true; isToolTipFadingIn = true;
} }
} }
@ -1864,7 +1864,7 @@ void GameView::NotifyNotificationsChanged(GameModel * sender)
int currentY = YRES-23; int currentY = YRES-23;
for (auto *notification : notifications) for (auto *notification : notifications)
{ {
int width = (Graphics::textwidth(notification->Message))+8; int width = Graphics::TextSize(notification->Message).X + 7;
ui::Button * tempButton = new ui::Button(ui::Point(XRES-width-22, currentY), ui::Point(width, 15), notification->Message); ui::Button * tempButton = new ui::Button(ui::Point(XRES-width-22, currentY), ui::Point(width, 15), notification->Message);
tempButton->SetActionCallback({ [notification] { tempButton->SetActionCallback({ [notification] {
notification->Action(); notification->Action();
@ -2197,8 +2197,8 @@ void GameView::OnDraw()
break; break;
} }
startY -= 14; startY -= 14;
g->fillrect(startX-3, startY-3, Graphics::textwidth(message)+6, 14, 0, 0, 0, std::min(100, alpha)); g->fillrect(startX-3, startY-3, Graphics::TextSize(message).X + 5, 14, 0, 0, 0, std::min(100, alpha));
g->drawtext(startX, startY, message, 255, 255, 255, alpha); g->BlendText({ startX, startY }, message, RGBA<uint8_t>(255, 255, 255, alpha));
(*iter).second -= 3; (*iter).second -= 3;
} }
} }
@ -2208,9 +2208,9 @@ void GameView::OnDraw()
{ {
String sampleInfo = String::Build("#", screenshotIndex, " ", String(0xE00E), " REC"); String sampleInfo = String::Build("#", screenshotIndex, " ", String(0xE00E), " REC");
int textWidth = Graphics::textwidth(sampleInfo); int textWidth = Graphics::TextSize(sampleInfo).X - 1;
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, 127); g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, 127);
g->drawtext(XRES-16-textWidth, 16, sampleInfo, 255, 50, 20, 255); g->BlendText({ XRES-16-textWidth, 16 }, sampleInfo, RGBA<uint8_t>(255, 50, 20, 255));
} }
else if(showHud) else if(showHud)
{ {
@ -2329,9 +2329,9 @@ void GameView::OnDraw()
sampleInfo << "Empty"; sampleInfo << "Empty";
} }
int textWidth = Graphics::textwidth(sampleInfo.Build()); int textWidth = Graphics::TextSize(sampleInfo.Build()).X - 1;
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, int(alpha*0.5f)); g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, int(alpha*0.5f));
g->drawtext(XRES-16-textWidth, 16, sampleInfo.Build(), 255, 255, 255, int(alpha*0.75f)); g->BlendText({ XRES-16-textWidth, 16 }, sampleInfo.Build(), RGBA<uint8_t>(255, 255, 255, int(alpha*0.75f)));
if (wavelengthGfx) if (wavelengthGfx)
{ {
@ -2387,9 +2387,9 @@ void GameView::OnDraw()
format::RenderTemperature(sampleInfo, sample.AirTemperature, c->GetTemperatureScale()); format::RenderTemperature(sampleInfo, sample.AirTemperature, c->GetTemperatureScale());
} }
textWidth = Graphics::textwidth(sampleInfo.Build()); auto textWidth = Graphics::TextSize(sampleInfo.Build()).X - 1;
g->fillrect(XRES-20-textWidth, 27, textWidth+8, 14, 0, 0, 0, int(alpha*0.5f)); g->fillrect(XRES-20-textWidth, 27, textWidth+8, 14, 0, 0, 0, int(alpha*0.5f));
g->drawtext(XRES-16-textWidth, 30, sampleInfo.Build(), 255, 255, 255, int(alpha*0.75f)); g->BlendText({ XRES-16-textWidth, 30 }, sampleInfo.Build(), RGBA<uint8_t>(255, 255, 255, int(alpha*0.75f)));
} }
} }
@ -2415,37 +2415,37 @@ void GameView::OnDraw()
if (ren && ren->findingElement) if (ren && ren->findingElement)
fpsInfo << " [FIND]"; fpsInfo << " [FIND]";
int textWidth = Graphics::textwidth(fpsInfo.Build()); int textWidth = Graphics::TextSize(fpsInfo.Build()).X - 1;
int alpha = 255-introText*5; int alpha = 255-introText*5;
g->fillrect(12, 12, textWidth+8, 15, 0, 0, 0, int(alpha*0.5)); g->fillrect(12, 12, textWidth+8, 15, 0, 0, 0, int(alpha*0.5));
g->drawtext(16, 16, fpsInfo.Build(), 32, 216, 255, int(alpha*0.75)); g->BlendText({ 16, 16 }, fpsInfo.Build(), RGBA<uint8_t>(32, 216, 255, int(alpha*0.75)));
} }
//Tooltips //Tooltips
if(infoTipPresence) if(infoTipPresence)
{ {
int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5; int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5;
g->drawtext_outline((XRES-Graphics::textwidth(infoTip))/2, (YRES/2)-2, infoTip, 255, 255, 255, infoTipAlpha); g->BlendTextOutline({ (XRES - (Graphics::TextSize(infoTip).X - 1)) / 2, YRES / 2 - 2 }, infoTip, RGBA<uint8_t>(255, 255, 255, infoTipAlpha));
} }
if(toolTipPresence && toolTipPosition.X!=-1 && toolTipPosition.Y!=-1 && toolTip.length()) if(toolTipPresence && toolTipPosition.X!=-1 && toolTipPosition.Y!=-1 && toolTip.length())
{ {
if (toolTipPosition.Y == Size.Y-MENUSIZE-10) if (toolTipPosition.Y == Size.Y-MENUSIZE-10)
g->drawtext_outline(toolTipPosition.X, toolTipPosition.Y, toolTip, 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5); g->BlendTextOutline(toolTipPosition, toolTip, RGBA<uint8_t>(255, 255, 255, toolTipPresence>51?255:toolTipPresence*5));
else else
g->drawtext(toolTipPosition.X, toolTipPosition.Y, toolTip, 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5); g->BlendText(toolTipPosition, toolTip, RGBA<uint8_t>(255, 255, 255, toolTipPresence>51?255:toolTipPresence*5));
} }
if(buttonTipShow > 0) if(buttonTipShow > 0)
{ {
g->drawtext(16, Size.Y-MENUSIZE-24, buttonTip, 255, 255, 255, buttonTipShow>51?255:buttonTipShow*5); g->BlendText({ 16, Size.Y-MENUSIZE-24 }, buttonTip, RGBA<uint8_t>(255, 255, 255, buttonTipShow>51?255:buttonTipShow*5));
} }
//Introduction text //Introduction text
if(introText && showHud) if(introText && showHud)
{ {
g->fillrect(0, 0, WINDOWW, WINDOWH, 0, 0, 0, introText>51?102:introText*2); g->fillrect(0, 0, WINDOWW, WINDOWH, 0, 0, 0, introText>51?102:introText*2);
g->drawtext(16, 16, introTextMessage, 255, 255, 255, introText>51?255:introText*5); g->BlendText({ 16, 16 }, introTextMessage, RGBA<uint8_t>(255, 255, 255, introText>51?255:introText*5));
} }
} }

View File

@ -170,7 +170,7 @@ void SignWindow::DoDraw()
String text = currentSign.getDisplayText(sim, x, y, w, h); String text = currentSign.getDisplayText(sim, x, y, w, h);
g->clearrect(x, y, w+1, h); g->clearrect(x, y, w+1, h);
g->drawrect(x, y, w+1, h, 192, 192, 192, 255); g->drawrect(x, y, w+1, h, 192, 192, 192, 255);
g->drawtext(x+3, y+4, text, 255, 255, 255, 255); g->BlendText({ x+3, y+4 }, text, RGBA<uint8_t>(255, 255, 255, 255));
if (currentSign.ju != sign::None) if (currentSign.ju != sign::None)
{ {

View File

@ -53,7 +53,8 @@ void ToolButton::Draw(const ui::Point& screenPos)
if (Appearance.GetTexture()) if (Appearance.GetTexture())
{ {
g->draw_image(Appearance.GetTexture(), screenPos.X+2, screenPos.Y+2, 255); auto *tex = Appearance.GetTexture();
g->BlendImage(tex->Data(), 255, RectSized(screenPos + Vec2{ 2, 2 }, tex->Size()));
} }
else else
{ {
@ -70,16 +71,16 @@ void ToolButton::Draw(const ui::Point& screenPos)
} }
if (Favorite::Ref().IsFavorite(toolIdentifier)) if (Favorite::Ref().IsFavorite(toolIdentifier))
{ {
g->drawtext(screenPos.X, screenPos.Y, 0xE068, Appearance.BorderFavorite.Red, Appearance.BorderFavorite.Green, Appearance.BorderFavorite.Blue, Appearance.BorderFavorite.Alpha); g->BlendText(screenPos, 0xE068, Appearance.BorderFavorite);
} }
if (totalColour<544) if (totalColour<544)
{ {
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, buttonDisplayText, 255, 255, 255, 255); g->BlendText(screenPos + textPosition, buttonDisplayText, RGBA<uint8_t>(255, 255, 255, 255));
} }
else else
{ {
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, buttonDisplayText, 0, 0, 0, 255); g->BlendText(screenPos + textPosition, buttonDisplayText, RGBA<uint8_t>(0, 0, 0, 255));
} }
if (ClipRect.Size().X && ClipRect.Size().Y) if (ClipRect.Size().X && ClipRect.Size().Y)

View File

@ -39,7 +39,8 @@ void AvatarButton::Draw(const Point& screenPos)
if(avatar) if(avatar)
{ {
g->draw_image(avatar.get(), screenPos.X, screenPos.Y, 255); auto *tex = avatar.get();
g->BlendImage(tex->Data(), 255, RectSized(screenPos, tex->Size()));
} }
} }

View File

@ -127,7 +127,7 @@ void Button::Draw(const Point& screenPos)
if(Appearance.Border.Right) if(Appearance.Border.Right)
g->draw_line(Position.X+Size.X-1, Position.Y, Position.X+Size.X-1, Position.Y+Size.Y-1, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha); g->draw_line(Position.X+Size.X-1, Position.Y, Position.X+Size.X-1, Position.Y+Size.Y-1, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha);
} }
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y, buttonDisplayText, textColour.Red, textColour.Green, textColour.Blue, textColour.Alpha); g->BlendText(Position + textPosition, buttonDisplayText, textColour);
bool iconInvert = (backgroundColour.Blue + (3*backgroundColour.Green) + (2*backgroundColour.Red))>544?true:false; bool iconInvert = (backgroundColour.Blue + (3*backgroundColour.Green) + (2*backgroundColour.Red))>544?true:false;

View File

@ -83,7 +83,7 @@ void Checkbox::Draw(const Point& screenPos)
g->drawrect(screenPos.X+2, screenPos.Y+2, 12, 12, 255, 255, 255, 255); g->drawrect(screenPos.X+2, screenPos.Y+2, 12, 12, 255, 255, 255, 255);
g->fillrect(screenPos.X+5, screenPos.Y+5, 6, 6, 255, 255, 255, 170); g->fillrect(screenPos.X+5, screenPos.Y+5, 6, 6, 255, 255, 255, 170);
if (!Appearance.icon) if (!Appearance.icon)
g->drawtext(screenPos.X+18, screenPos.Y+4, text, 255, 255, 255, 255); g->BlendText(screenPos + Vec2{ 18, 4 }, text, RGBA<uint8_t>(255, 255, 255, 255));
else else
g->draw_icon(screenPos.X+iconPosition.X, screenPos.Y+iconPosition.Y, Appearance.icon, 255); g->draw_icon(screenPos.X+iconPosition.X, screenPos.Y+iconPosition.Y, Appearance.icon, 255);
} }
@ -91,7 +91,7 @@ void Checkbox::Draw(const Point& screenPos)
{ {
g->drawrect(screenPos.X+2, screenPos.Y+2, 12, 12, 255, 255, 255, 200); g->drawrect(screenPos.X+2, screenPos.Y+2, 12, 12, 255, 255, 255, 200);
if (!Appearance.icon) if (!Appearance.icon)
g->drawtext(screenPos.X+18, screenPos.Y+4, text, 255, 255, 255, 200); g->BlendText(screenPos + Vec2{ 18, 4 }, text, RGBA<uint8_t>(255, 255, 255, 200));
else else
g->draw_icon(screenPos.X+iconPosition.X, screenPos.Y+iconPosition.Y, Appearance.icon, 200); g->draw_icon(screenPos.X+iconPosition.X, screenPos.Y+iconPosition.Y, Appearance.icon, 200);
} }

View File

@ -101,7 +101,7 @@ void DropDown::Draw(const Point& screenPos)
g->fillrect(Position.X-1, Position.Y-1, Size.X+2, Size.Y+2, backgroundColour.Red, backgroundColour.Green, backgroundColour.Blue, backgroundColour.Alpha); g->fillrect(Position.X-1, Position.Y-1, Size.X+2, Size.Y+2, backgroundColour.Red, backgroundColour.Green, backgroundColour.Blue, backgroundColour.Alpha);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha);
if(optionIndex!=-1) if(optionIndex!=-1)
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y, options[optionIndex].first, textColour.Red, textColour.Green, textColour.Blue, textColour.Alpha); g->BlendText(Position + textPosition, options[optionIndex].first, textColour);
} }
void DropDown::OnMouseEnter(int x, int y) void DropDown::OnMouseEnter(int x, int y)

View File

@ -285,11 +285,10 @@ void Label::Draw(const Point& screenPos)
} }
} }
g->drawtext( g->BlendText(
screenPos.X + textPosition.X, screenPos + textPosition,
screenPos.Y + textPosition.Y,
displayTextWithSelection, displayTextWithSelection,
textColour.Red, textColour.Green, textColour.Blue, 255 RGBA<uint8_t>(textColour.Red, textColour.Green, textColour.Blue, 255)
); );
} }

View File

@ -72,10 +72,7 @@ void ProgressBar::Draw(const Point & screenPos)
g->fillrect(screenPos.X + 2, screenPos.Y + 2, rsize, Size.Y-4, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255); g->fillrect(screenPos.X + 2, screenPos.Y + 2, rsize, Size.Y-4, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255);
} }
} }
if(progress<50) g->BlendText(screenPos + Vec2{ ((Size.X-(Graphics::TextSize(progressStatus).X - 1))/2), (Size.Y-8)/2 }, progressStatus, progress<50 ? RGBA<uint8_t>(255, 255, 255, 255) : RGBA<uint8_t>(0, 0, 0, 255));
g->drawtext(screenPos.X + ((Size.X-Graphics::textwidth(progressStatus))/2), screenPos.Y + (Size.Y-8)/2, progressStatus, 255, 255, 255, 255);
else
g->drawtext(screenPos.X + ((Size.X-Graphics::textwidth(progressStatus))/2), screenPos.Y + (Size.Y-8)/2, progressStatus, 0, 0, 0, 255);
} }
void ProgressBar::Tick(float dt) void ProgressBar::Tick(float dt)

View File

@ -179,7 +179,7 @@ void RichLabel::Draw(const Point& screenPos)
{ {
Graphics * g = GetGraphics(); Graphics * g = GetGraphics();
ui::Colour textColour = Appearance.TextInactive; ui::Colour textColour = Appearance.TextInactive;
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, displayText, textColour.Red, textColour.Green, textColour.Blue, 255); g->BlendText(screenPos + textPosition, displayText, RGBA<uint8_t>(textColour.Red, textColour.Green, textColour.Blue, 255));
} }
void RichLabel::OnMouseClick(int x, int y, unsigned button) void RichLabel::OnMouseClick(int x, int y, unsigned button)

View File

@ -194,13 +194,12 @@ void SaveButton::Draw(const Point& screenPos)
if (thumbnail) if (thumbnail)
{ {
//thumbBoxSize = ui::Point(thumbnail->Width, thumbnail->Height); //thumbBoxSize = ui::Point(thumbnail->Width, thumbnail->Height);
if (save && save->id) auto *tex = thumbnail.get();
g->draw_image(thumbnail.get(), screenPos.X-3+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, 255); auto space = Size - Vec2{ 0, 21 };
else g->BlendImage(tex->Data(), 255, RectSized(screenPos + ((save && save->id) ? ((space - thumbBoxSize) / 2 - Vec2{ 3, 0 }) : (space - thumbSize) / 2), tex->Size()));
g->draw_image(thumbnail.get(), screenPos.X+(Size.X-thumbSize.X)/2, screenPos.Y+(Size.Y-21-thumbSize.Y)/2, 255);
} }
else if (file && !file->GetGameSave()) else if (file && !file->GetGameSave())
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth("Error loading save"))/2, screenPos.Y+(Size.Y-28)/2, "Error loading save", 180, 180, 180, 255); g->BlendText(screenPos + Vec2{ (Size.X-(Graphics::TextSize("Error loading save").X - 1))/2, (Size.Y-28)/2 }, "Error loading save", RGBA<uint8_t>(180, 180, 180, 255));
if(save) if(save)
{ {
if(save->id) if(save->id)
@ -230,38 +229,27 @@ void SaveButton::Draw(const Point& screenPos)
g->drawrect(screenPos.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 180, 180, 180, 255); g->drawrect(screenPos.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 180, 180, 180, 255);
} }
if(isMouseInside && !isMouseInsideAuthor) g->BlendText(screenPos + Vec2{ (Size.X-(Graphics::TextSize(name).X - 1))/2, Size.Y - 21 }, name, (isMouseInside && !isMouseInsideAuthor) ? RGBA<uint8_t>(255, 255, 255, 255) : RGBA<uint8_t>(180, 180, 180, 255));
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth(name))/2, screenPos.Y+Size.Y - 21, name, 255, 255, 255, 255); g->BlendText(screenPos + Vec2{ (Size.X-(Graphics::TextSize(save->userName.FromUtf8()).X - 1))/2, Size.Y - 10 }, save->userName.FromUtf8(), isMouseInsideAuthor ? RGBA<uint8_t>(200, 230, 255, 255) : RGBA<uint8_t>(100, 130, 160, 255));
else
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth(name))/2, screenPos.Y+Size.Y - 21, name, 180, 180, 180, 255);
if(isMouseInsideAuthor)
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth(save->userName.FromUtf8()))/2, screenPos.Y+Size.Y - 10, save->userName.FromUtf8(), 200, 230, 255, 255);
else
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth(save->userName.FromUtf8()))/2, screenPos.Y+Size.Y - 10, save->userName.FromUtf8(), 100, 130, 160, 255);
if (showVotes)// && !isMouseInside) if (showVotes)// && !isMouseInside)
{ {
int x = screenPos.X-7+(Size.X-thumbBoxSize.X)/2+thumbBoxSize.X-Graphics::textwidth(votesBackground); int x = screenPos.X-7+(Size.X-thumbBoxSize.X)/2+thumbBoxSize.X-(Graphics::TextSize(votesBackground).X - 1);
int y = screenPos.Y-23+(Size.Y-thumbBoxSize.Y)/2+thumbBoxSize.Y; int y = screenPos.Y-23+(Size.Y-thumbBoxSize.Y)/2+thumbBoxSize.Y;
g->drawtext(x, y, votesBackground, 16, 72, 16, 255); g->BlendText({ x, y }, votesBackground, RGBA<uint8_t>(16, 72, 16, 255));
g->drawtext(x, y, votesBackground2, 192, 192, 192, 255); g->BlendText({ x, y }, votesBackground2, RGBA<uint8_t>(192, 192, 192, 255));
g->drawtext(x+3, y, votesString, 255, 255, 255, 255); g->BlendText({ x+3, y }, votesString, RGBA<uint8_t>(255, 255, 255, 255));
} }
if (isMouseInsideHistory && showVotes) if (isMouseInsideHistory && showVotes)
{ {
int x = screenPos.X; int x = screenPos.X;
int y = screenPos.Y-15+(Size.Y-thumbBoxSize.Y)/2+thumbBoxSize.Y; int y = screenPos.Y-15+(Size.Y-thumbBoxSize.Y)/2+thumbBoxSize.Y;
g->fillrect(x+1, y+1, 7, 8, 255, 255, 255, 255); g->fillrect(x+1, y+1, 7, 8, 255, 255, 255, 255);
if (isMouseInsideHistory) { g->BlendText({ x, y }, 0xE026, isMouseInsideHistory ? RGBA<uint8_t>(200, 100, 80, 255) : RGBA<uint8_t>(160, 70, 50, 255));
g->drawtext(x, y, 0xE026, 200, 100, 80, 255);
} else {
g->drawtext(x, y, 0xE026, 160, 70, 50, 255);
}
} }
if (!save->GetPublished()) if (!save->GetPublished())
{ {
g->drawtext(screenPos.X, screenPos.Y-2, 0xE04D, 255, 255, 255, 255); g->BlendText(screenPos - Vec2{ 0, 2 }, 0xE04D, RGBA<uint8_t>(255, 255, 255, 255));
g->drawtext(screenPos.X, screenPos.Y-2, 0xE04E, 212, 151, 81, 255); g->BlendText(screenPos - Vec2{ 0, 2 }, 0xE04E, RGBA<uint8_t>(212, 151, 81, 255));
} }
} }
else if (file) else if (file)
@ -273,14 +261,7 @@ void SaveButton::Draw(const Point& screenPos)
if (thumbSize.X) if (thumbSize.X)
g->xor_rect(screenPos.X+(Size.X-thumbSize.X)/2, screenPos.Y+(Size.Y-21-thumbSize.Y)/2, thumbSize.X, thumbSize.Y); g->xor_rect(screenPos.X+(Size.X-thumbSize.X)/2, screenPos.Y+(Size.Y-21-thumbSize.Y)/2, thumbSize.X, thumbSize.Y);
if (isMouseInside) g->BlendText(screenPos + Vec2{ (Size.X-(Graphics::TextSize(name).X - 1))/2, Size.Y - 21 }, name, isMouseInside ? RGBA<uint8_t>(255, 255, 255, 255) : RGBA<uint8_t>(180, 180, 180, 255));
{
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth(name))/2, screenPos.Y+Size.Y - 21, name, 255, 255, 255, 255);
}
else
{
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth(name))/2, screenPos.Y+Size.Y - 21, name, 180, 180, 180, 255);
}
} }
if(isMouseInside && selectable) if(isMouseInside && selectable)

View File

@ -200,9 +200,9 @@ void Textbox::pasteIntoSelection()
{ {
newText = newText.Substr(0, limit-backingText.length()); newText = newText.Substr(0, limit-backingText.length());
} }
if (!multiline && Graphics::textwidth(backingText + newText) > regionWidth) if (!multiline && Graphics::TextSize(backingText + newText).X - 1 > regionWidth)
{ {
int pLimit = regionWidth - Graphics::textwidth(backingText); int pLimit = regionWidth - (Graphics::TextSize(backingText).X - 1);
int pWidth = 0; int pWidth = 0;
auto it = newText.begin(); auto it = newText.begin();
while (it != newText.end()) while (it != newText.end())
@ -488,7 +488,7 @@ void Textbox::InsertText(String text)
regionWidth -= 13; regionWidth -= 13;
regionWidth -= Appearance.Margin.Left; regionWidth -= Appearance.Margin.Left;
regionWidth -= Appearance.Margin.Right; regionWidth -= Appearance.Margin.Right;
if ((limit==String::npos || backingText.length() < limit) && (Graphics::textwidth(backingText + text) <= regionWidth || multiline)) if ((limit==String::npos || backingText.length() < limit) && (Graphics::TextSize(backingText + text).X - 1 <= regionWidth || multiline))
{ {
if (cursor == (int)backingText.length()) if (cursor == (int)backingText.length())
{ {
@ -620,7 +620,7 @@ void Textbox::Draw(const Point& screenPos)
{ {
if(!text.length()) if(!text.length())
{ {
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, placeHolder, textColour.Red, textColour.Green, textColour.Blue, 170); g->BlendText(screenPos + textPosition, placeHolder, RGBA<uint8_t>(textColour.Red, textColour.Green, textColour.Blue, 170));
} }
if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 160, 160, 160, 255); if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 160, 160, 160, 255);
} }

View File

@ -218,8 +218,8 @@ void Window::DoDraw()
); );
auto pos = focusedComponent_->Position + Position + Vec2(focusedComponent_->Size.X + 5, 0); auto pos = focusedComponent_->Position + Position + Vec2(focusedComponent_->Size.X + 5, 0);
pos.X = std::min(pos.X, g->Size().X - Graphics::textwidth(posText) - 5); pos.X = std::min(pos.X, g->Size().X - (Graphics::TextSize(posText).X - 1) - 5);
pos.X = std::min(pos.X, g->Size().X - Graphics::textwidth(sizeText) - 5); pos.X = std::min(pos.X, g->Size().X - (Graphics::TextSize(sizeText).X - 1) - 5);
g->BlendText(pos + Vec2(0, 1), posText, 0x000000_rgb .WithAlpha(0xC8)); g->BlendText(pos + Vec2(0, 1), posText, 0x000000_rgb .WithAlpha(0xC8));
g->BlendText(pos + Vec2(0, 0), posText, 0xFFFFFF_rgb .WithAlpha(0xFF)); g->BlendText(pos + Vec2(0, 0), posText, 0xFFFFFF_rgb .WithAlpha(0xFF));

View File

@ -83,7 +83,7 @@ void LocalBrowserView::NotifyPageChanged(LocalBrowserModel * sender)
{ {
String pageInfo = String::Build("of ", pageCount); String pageInfo = String::Build("of ", pageCount);
pageCountLabel->SetText(pageInfo); pageCountLabel->SetText(pageInfo);
int width = Graphics::textwidth(pageInfo); int width = Graphics::TextSize(pageInfo).X - 1;
pageLabel->Position.X = WINDOWW/2-width-20; pageLabel->Position.X = WINDOWW/2-width-20;
pageTextbox->Position.X = WINDOWW/2-width+11; pageTextbox->Position.X = WINDOWW/2-width+11;

View File

@ -281,7 +281,7 @@ OptionsView::OptionsView():
resizable = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Resizable", ""); resizable = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Resizable", "");
autowidth(resizable); autowidth(resizable);
resizable->SetActionCallback({ [this] { c->SetResizable(resizable->GetChecked()); } }); resizable->SetActionCallback({ [this] { c->SetResizable(resizable->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(resizable->Position.X+Graphics::textwidth(resizable->GetText())+20, currentY), ui::Point(1, 16), "\bg- Allow resizing and maximizing window"); tempLabel = new ui::Label(ui::Point(resizable->Position.X+Graphics::TextSize(resizable->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Allow resizing and maximizing window");
autowidth(tempLabel); autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -292,7 +292,7 @@ OptionsView::OptionsView():
fullscreen = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Fullscreen", ""); fullscreen = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Fullscreen", "");
autowidth(fullscreen); autowidth(fullscreen);
fullscreen->SetActionCallback({ [this] { c->SetFullscreen(fullscreen->GetChecked()); } }); fullscreen->SetActionCallback({ [this] { c->SetFullscreen(fullscreen->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(fullscreen->Position.X+Graphics::textwidth(fullscreen->GetText())+20, currentY), ui::Point(1, 16), "\bg- Fill the entire screen"); tempLabel = new ui::Label(ui::Point(fullscreen->Position.X+Graphics::TextSize(fullscreen->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Fill the entire screen");
autowidth(tempLabel); autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -303,7 +303,7 @@ OptionsView::OptionsView():
altFullscreen = new ui::Checkbox(ui::Point(23, currentY), ui::Point(1, 16), "Change Resolution", ""); altFullscreen = new ui::Checkbox(ui::Point(23, currentY), ui::Point(1, 16), "Change Resolution", "");
autowidth(altFullscreen); autowidth(altFullscreen);
altFullscreen->SetActionCallback({ [this] { c->SetAltFullscreen(altFullscreen->GetChecked()); } }); altFullscreen->SetActionCallback({ [this] { c->SetAltFullscreen(altFullscreen->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::textwidth(altFullscreen->GetText())+20, currentY), ui::Point(1, 16), "\bg- Set optimal screen resolution"); tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::TextSize(altFullscreen->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Set optimal screen resolution");
autowidth(tempLabel); autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -314,7 +314,7 @@ OptionsView::OptionsView():
forceIntegerScaling = new ui::Checkbox(ui::Point(23, currentY), ui::Point(1, 16), "Force Integer Scaling", ""); forceIntegerScaling = new ui::Checkbox(ui::Point(23, currentY), ui::Point(1, 16), "Force Integer Scaling", "");
autowidth(forceIntegerScaling); autowidth(forceIntegerScaling);
forceIntegerScaling->SetActionCallback({ [this] { c->SetForceIntegerScaling(forceIntegerScaling->GetChecked()); } }); forceIntegerScaling->SetActionCallback({ [this] { c->SetForceIntegerScaling(forceIntegerScaling->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::textwidth(forceIntegerScaling->GetText())+20, currentY), ui::Point(1, 16), "\bg- Less blurry"); tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::TextSize(forceIntegerScaling->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Less blurry");
autowidth(tempLabel); autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -325,7 +325,7 @@ OptionsView::OptionsView():
fastquit = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Fast Quit", ""); fastquit = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Fast Quit", "");
autowidth(fastquit); autowidth(fastquit);
fastquit->SetActionCallback({ [this] { c->SetFastQuit(fastquit->GetChecked()); } }); fastquit->SetActionCallback({ [this] { c->SetFastQuit(fastquit->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(fastquit->Position.X+Graphics::textwidth(fastquit->GetText())+20, currentY), ui::Point(1, 16), "\bg- Always exit completely when hitting close"); tempLabel = new ui::Label(ui::Point(fastquit->Position.X+Graphics::TextSize(fastquit->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Always exit completely when hitting close");
autowidth(tempLabel); autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -336,7 +336,7 @@ OptionsView::OptionsView():
showAvatars = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Show Avatars", ""); showAvatars = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Show Avatars", "");
autowidth(showAvatars); autowidth(showAvatars);
showAvatars->SetActionCallback({ [this] { c->SetShowAvatars(showAvatars->GetChecked()); } }); showAvatars->SetActionCallback({ [this] { c->SetShowAvatars(showAvatars->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(showAvatars->Position.X+Graphics::textwidth(showAvatars->GetText())+20, currentY), ui::Point(1, 16), "\bg- Disable if you have a slow connection"); tempLabel = new ui::Label(ui::Point(showAvatars->Position.X+Graphics::TextSize(showAvatars->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Disable if you have a slow connection");
autowidth(tempLabel); autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -347,7 +347,7 @@ OptionsView::OptionsView():
momentumScroll = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Momentum/Old Scrolling", ""); momentumScroll = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Momentum/Old Scrolling", "");
autowidth(momentumScroll); autowidth(momentumScroll);
momentumScroll->SetActionCallback({ [this] { c->SetMomentumScroll(momentumScroll->GetChecked()); } }); momentumScroll->SetActionCallback({ [this] { c->SetMomentumScroll(momentumScroll->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(momentumScroll->Position.X + Graphics::textwidth(momentumScroll->GetText()) + 20, currentY), ui::Point(1, 16), "\bg- Accelerating instead of step scroll"); tempLabel = new ui::Label(ui::Point(momentumScroll->Position.X + Graphics::TextSize(momentumScroll->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Accelerating instead of step scroll");
autowidth(tempLabel); autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -358,7 +358,7 @@ OptionsView::OptionsView():
mouseClickRequired = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Sticky Categories", ""); mouseClickRequired = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Sticky Categories", "");
autowidth(mouseClickRequired); autowidth(mouseClickRequired);
mouseClickRequired->SetActionCallback({ [this] { c->SetMouseClickrequired(mouseClickRequired->GetChecked()); } }); mouseClickRequired->SetActionCallback({ [this] { c->SetMouseClickrequired(mouseClickRequired->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(mouseClickRequired->Position.X+Graphics::textwidth(mouseClickRequired->GetText())+20, currentY), ui::Point(1, 16), "\bg- Switch between categories by clicking"); tempLabel = new ui::Label(ui::Point(mouseClickRequired->Position.X+Graphics::TextSize(mouseClickRequired->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Switch between categories by clicking");
autowidth(tempLabel); autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -369,7 +369,7 @@ OptionsView::OptionsView():
includePressure = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Include Pressure", ""); includePressure = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Include Pressure", "");
autowidth(includePressure); autowidth(includePressure);
includePressure->SetActionCallback({ [this] { c->SetIncludePressure(includePressure->GetChecked()); } }); includePressure->SetActionCallback({ [this] { c->SetIncludePressure(includePressure->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(includePressure->Position.X+Graphics::textwidth(includePressure->GetText())+20, currentY), ui::Point(1, 16), "\bg- When saving, copying, stamping, etc."); tempLabel = new ui::Label(ui::Point(includePressure->Position.X+Graphics::TextSize(includePressure->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- When saving, copying, stamping, etc.");
autowidth(tempLabel); autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -380,7 +380,7 @@ OptionsView::OptionsView():
perfectCirclePressure = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Perfect Circle", ""); perfectCirclePressure = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Perfect Circle", "");
autowidth(perfectCirclePressure); autowidth(perfectCirclePressure);
perfectCirclePressure->SetActionCallback({ [this] { c->SetPerfectCircle(perfectCirclePressure->GetChecked()); } }); perfectCirclePressure->SetActionCallback({ [this] { c->SetPerfectCircle(perfectCirclePressure->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(perfectCirclePressure->Position.X+Graphics::textwidth(perfectCirclePressure->GetText())+20, currentY), ui::Point(1, 16), "\bg- Better circle brush, without incorrect points on edges"); tempLabel = new ui::Label(ui::Point(perfectCirclePressure->Position.X+Graphics::TextSize(perfectCirclePressure->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Better circle brush, without incorrect points on edges");
autowidth(tempLabel); autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;

View File

@ -149,13 +149,13 @@ void PreviewView::AttachController(PreviewController * controller)
{ {
c = controller; c = controller;
int textWidth = Graphics::textwidth("Click the box below to copy the save ID"); int textWidth = Graphics::TextSize("Click the box below to copy the save ID").X - 1;
saveIDLabel = new ui::Label(ui::Point((Size.X-textWidth-20)/2, Size.Y+5), ui::Point(textWidth+20, 16), "Click the box below to copy the save ID"); saveIDLabel = new ui::Label(ui::Point((Size.X-textWidth-20)/2, Size.Y+5), ui::Point(textWidth+20, 16), "Click the box below to copy the save ID");
saveIDLabel->SetTextColour(ui::Colour(150, 150, 150)); saveIDLabel->SetTextColour(ui::Colour(150, 150, 150));
saveIDLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; saveIDLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
AddComponent(saveIDLabel); AddComponent(saveIDLabel);
textWidth = Graphics::textwidth(String::Build(c->SaveID())); textWidth = Graphics::TextSize(String::Build(c->SaveID())).X - 1;
saveIDLabel2 = new ui::Label(ui::Point((Size.X-textWidth-20)/2-37, Size.Y+22), ui::Point(40, 16), "Save ID:"); saveIDLabel2 = new ui::Label(ui::Point((Size.X-textWidth-20)/2-37, Size.Y+22), ui::Point(40, 16), "Save ID:");
AddComponent(saveIDLabel2); AddComponent(saveIDLabel2);
@ -167,7 +167,7 @@ void PreviewView::commentBoxAutoHeight()
{ {
if(!addCommentBox) if(!addCommentBox)
return; return;
int textWidth = Graphics::textwidth(addCommentBox->GetText().c_str()); int textWidth = Graphics::TextSize(addCommentBox->GetText().c_str()).X - 1;
if (commentHelpText || textWidth+15 > Size.X-(XRES/2)-48) if (commentHelpText || textWidth+15 > Size.X-(XRES/2)-48)
{ {
addCommentBox->Appearance.VerticalAlign = ui::Appearance::AlignTop; addCommentBox->Appearance.VerticalAlign = ui::Appearance::AlignTop;
@ -271,7 +271,7 @@ void PreviewView::DoDraw()
{ {
g->fillrect(Position.X+(Size.X/2)-101, Position.Y+(Size.Y/2)-26, 202, 52, 0, 0, 0, 210); g->fillrect(Position.X+(Size.X/2)-101, Position.Y+(Size.Y/2)-26, 202, 52, 0, 0, 0, 210);
g->drawrect(Position.X+(Size.X/2)-100, Position.Y+(Size.Y/2)-25, 200, 50, 255, 255, 255, 180); g->drawrect(Position.X+(Size.X/2)-100, Position.Y+(Size.Y/2)-25, 200, 50, 255, 255, 255, 180);
g->drawtext(Position.X+(Size.X/2)-(Graphics::textwidth("Loading save...")/2), Position.Y+(Size.Y/2)-5, "Loading save...", style::Colour::InformationTitle.Red, style::Colour::InformationTitle.Green, style::Colour::InformationTitle.Blue, 255); g->BlendText(Position + Vec2{(Size.X/2)-((Graphics::TextSize("Loading save...").X - 1)/2), (Size.Y/2)-5}, "Loading save...", RGBA<uint8_t>(style::Colour::InformationTitle.Red, style::Colour::InformationTitle.Green, style::Colour::InformationTitle.Blue, 255));
} }
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);

View File

@ -170,7 +170,7 @@ void RenderView::OnDraw()
g->draw_line(XRES, 0, XRES, WINDOWH, 255, 255, 255, 255); g->draw_line(XRES, 0, XRES, WINDOWH, 255, 255, 255, 255);
if(toolTipPresence && toolTip.length()) if(toolTipPresence && toolTip.length())
{ {
g->drawtext(6, Size.Y-MENUSIZE-12, toolTip, 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5); g->BlendText({ 6, Size.Y-MENUSIZE-12 }, toolTip, RGBA<uint8_t>(255, 255, 255, toolTipPresence>51?255:toolTipPresence*5));
} }
} }

View File

@ -271,7 +271,7 @@ void SearchView::NotifyPageChanged(SearchModel * sender)
{ {
String pageInfo = String::Build("of ", pageCount); String pageInfo = String::Build("of ", pageCount);
pageCountLabel->SetText(pageInfo); pageCountLabel->SetText(pageInfo);
int width = Graphics::textwidth(pageInfo); int width = Graphics::TextSize(pageInfo).X - 1;
pageLabel->Position.X = WINDOWW/2-width-20; pageLabel->Position.X = WINDOWW/2-width-20;
pageTextbox->Position.X = WINDOWW/2-width+11; pageTextbox->Position.X = WINDOWW/2-width+11;

View File

@ -332,7 +332,7 @@ int luatpt_drawtext(lua_State* l)
if (textalpha<0) textalpha = 0; if (textalpha<0) textalpha = 0;
if (textalpha>255) textalpha = 255; if (textalpha>255) textalpha = 255;
luacon_g->drawtext(textx, texty, string, textred, textgreen, textblue, textalpha); luacon_g->BlendText({ textx, texty }, string, RGBA<uint8_t>(textred, textgreen, textblue, textalpha));
return 0; return 0;
} }
@ -983,7 +983,7 @@ int luatpt_drawline(lua_State* l)
int luatpt_textwidth(lua_State* l) int luatpt_textwidth(lua_State* l)
{ {
auto string = tpt_lua_optString(l, 1, ""); auto string = tpt_lua_optString(l, 1, "");
int strwidth = Graphics::textwidth(string); int strwidth = Graphics::TextSize(string).X - 1;
lua_pushinteger(l, strwidth); lua_pushinteger(l, strwidth);
return 1; return 1;
} }

View File

@ -3812,7 +3812,7 @@ int LuaScriptInterface::graphics_drawText(lua_State * l)
if (a<0) a = 0; if (a<0) a = 0;
else if (a>255) a = 255; else if (a>255) a = 255;
luacon_g->drawtext(x, y, text, r, g, b, a); luacon_g->BlendText({ x, y }, text, RGBA<uint8_t>(r, g, b, a));
return 0; return 0;
} }

View File

@ -134,7 +134,7 @@ String sign::getDisplayText(Simulation *sim, int &x0, int &y0, int &w, int &h, b
} }
} }
w = Graphics::textwidth(drawable_text.c_str()) + 5; w = Graphics::TextSize(drawable_text.c_str()).X + 4;
h = 15; h = 15;
x0 = (ju == Right) ? x - w : (ju == Left) ? x : x - w/2; x0 = (ju == Right) ? x - w : (ju == Left) ? x : x - w/2;
y0 = (y > 18) ? y - 18 : y + 4; y0 = (y > 18) ? y - 18 : y + 4;

View File

@ -117,10 +117,7 @@ void TaskWindow::OnDraw()
g->fillrect(Position.X + 2, Position.Y + Size.Y-15, rsize, 13, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255); g->fillrect(Position.X + 2, Position.Y + Size.Y-15, rsize, 13, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255);
} }
} }
if(progress<50) g->BlendText(Position + Vec2{ ((Size.X-(Graphics::TextSize(progressStatus).X - 1))/2), Size.Y-13 }, progressStatus, progress<50 ? RGBA<uint8_t>(255, 255, 255, 255) : RGBA<uint8_t>(0, 0, 0, 255));
g->drawtext(Position.X + ((Size.X-Graphics::textwidth(progressStatus))/2), Position.Y + Size.Y-13, progressStatus, 255, 255, 255, 255);
else
g->drawtext(Position.X + ((Size.X-Graphics::textwidth(progressStatus))/2), Position.Y + Size.Y-13, progressStatus, 0, 0, 0, 255);
} }
TaskWindow::~TaskWindow() { TaskWindow::~TaskWindow() {