Skip to content

Commit

Permalink
Fix some deprecation warnings
Browse files Browse the repository at this point in the history
Namely:

 - [[deprecated("Use DrawPixel/BlendPixel")]]
 - [[deprecated("Use DrawLine/BlendLine")]]
 - [[deprecated("Use DrawRect/BlendRect")]]
 - [[deprecated("Use DrawFilledRect/BlendFilledRect")]]
  • Loading branch information
LBPHacker committed Apr 30, 2023
1 parent 9fbb780 commit 410dc71
Show file tree
Hide file tree
Showing 47 changed files with 317 additions and 345 deletions.
2 changes: 1 addition & 1 deletion src/PowderToyRenderer.cpp
Expand Up @@ -62,7 +62,7 @@ int main(int argc, char *argv[])
else
{
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(RectSized(Vec2{ x, y }, Vec2{ w, 24 }), RGB<uint8_t>(192, 192, 192));
ren->BlendText({ x+8, y+8 }, "Save file invalid", RGBA<uint8_t>(192, 192, 240, 255));
}

Expand Down
9 changes: 4 additions & 5 deletions src/debug/DebugLines.cpp
Expand Up @@ -21,13 +21,12 @@ void DebugLines::Draw()
ui::Point drawPoint1 = controller->PointTranslate(view->GetLineStartCoords()), drawPoint2 = controller->PointTranslate(view->GetLineFinishCoords());
if (view->GetDrawSnap())
drawPoint2 = view->lineSnapCoords(drawPoint1, drawPoint2);
//g->draw_line(drawPoint1.X, drawPoint1.Y, drawPoint2.X, drawPoint2.Y, 255, 0, 255, 255);

g->draw_line(0, drawPoint1.Y, XRES, drawPoint1.Y, 255, 255, 255, 120);
g->draw_line(drawPoint1.X, 0, drawPoint1.X, YRES, 255, 255, 255, 120);
g->BlendLine({ 0, drawPoint1.Y }, { XRES, drawPoint1.Y }, RGBA<uint8_t>(255, 255, 255, 120));
g->BlendLine({ drawPoint1.X, 0 }, { drawPoint1.X, YRES }, RGBA<uint8_t>(255, 255, 255, 120));

g->draw_line(0, drawPoint2.Y, XRES, drawPoint2.Y, 255, 255, 255, 120);
g->draw_line(drawPoint2.X, 0, drawPoint2.X, YRES, 255, 255, 255, 120);
g->BlendLine({ 0, drawPoint2.Y }, { XRES, drawPoint2.Y }, RGBA<uint8_t>(255, 255, 255, 120));
g->BlendLine({ drawPoint2.X, 0 }, { drawPoint2.X, YRES }, RGBA<uint8_t>(255, 255, 255, 120));

String info;
info = String::Build(drawPoint2.X, " x ", drawPoint2.Y);
Expand Down
6 changes: 3 additions & 3 deletions src/debug/DebugParts.cpp
Expand Up @@ -38,16 +38,16 @@ void DebugParts::Draw()
x = 0;
}
}
g->draw_line(0, lpy, XRES, lpy, 0, 255, 120, 255);
g->draw_line(lpx, 0, lpx, YRES, 0, 255, 120, 255);
g->DrawLine({ 0, lpy }, { XRES, lpy }, RGB<uint8_t>(0, 255, 120));
g->DrawLine({ lpx, 0 }, { lpx, YRES }, RGB<uint8_t>(0, 255, 120));
g->AddPixel({ lpx, lpy }, RGBA<uint8_t>(255, 50, 50, 220));

g->AddPixel({ lpx+1, lpy }, RGBA<uint8_t>(255, 50, 50, 120));
g->AddPixel({ lpx-1, lpy }, RGBA<uint8_t>(255, 50, 50, 120));
g->AddPixel({ lpx, lpy+1 }, RGBA<uint8_t>(255, 50, 50, 120));
g->AddPixel({ lpx, lpy-1 }, RGBA<uint8_t>(255, 50, 50, 120));

g->fillrect(7, YRES-26, g->TextSize(info).X + 4, 14, 0, 0, 0, 180);
g->BlendFilledRect(RectSized(Vec2{ 7, YRES-26}, Vec2{ g->TextSize(info).X + 4, 14}), RGBA<uint8_t>(0, 0, 0, 180));
g->BlendText({ 10, YRES-22 }, info, RGBA<uint8_t>(255, 255, 255, 255));
}

Expand Down
14 changes: 7 additions & 7 deletions src/debug/ElementPopulation.cpp
Expand Up @@ -44,7 +44,7 @@ void ElementPopulationDebug::Draw()
halfValString = String::Build(maxAverage/2);


g->fillrect(xStart-5, yBottom - 263, bars+10+Graphics::TextSize(maxValString).X+9, 255 + 13, 0, 0, 0, 180);
g->BlendFilledRect(RectSized(Vec2{ xStart-5, yBottom - 263 }, Vec2{ bars+10+Graphics::TextSize(maxValString).X+9, 255 + 13 }), RGBA<uint8_t>(0, 0, 0, 180));

bars = 0;
for(int i = 0; i < PT_NUM; i++)
Expand All @@ -57,20 +57,20 @@ void ElementPopulationDebug::Draw()

RGB<uint8_t> colour = sim->elements[i].Colour;

g->draw_line(xStart+barX, yBottom+3, xStart+barX, yBottom+2, colour.Red, colour.Green, colour.Blue, 255);
g->DrawLine({ xStart+barX, yBottom+3 }, { xStart+barX, yBottom+2 }, colour);
if(sim->elementCount[i])
{
if(barSize > 256)
{
barSize = 256;
g->blendpixel(xStart+barX, yBottom-barSize-3, colour.Red, colour.Green, colour.Blue, 255);
g->blendpixel(xStart+barX, yBottom-barSize-5, colour.Red, colour.Green, colour.Blue, 255);
g->blendpixel(xStart+barX, yBottom-barSize-7, colour.Red, colour.Green, colour.Blue, 255);
g->DrawPixel({ xStart+barX, yBottom-barSize-3 }, colour);
g->DrawPixel({ xStart+barX, yBottom-barSize-5 }, colour);
g->DrawPixel({ xStart+barX, yBottom-barSize-7 }, colour);
} else {

g->draw_line(xStart+barX, yBottom-barSize-3, xStart+barX, yBottom-barSize-2, 255, 255, 255, 180);
g->BlendLine({ xStart+barX, yBottom-barSize-3 }, { xStart+barX, yBottom-barSize-2 }, RGBA<uint8_t>(255, 255, 255, 180));
}
g->draw_line(xStart+barX, yBottom-barSize, xStart+barX, yBottom, colour.Red, colour.Green, colour.Blue, 255);
g->DrawLine({ xStart+barX, yBottom-barSize }, { xStart+barX, yBottom }, colour);
}
bars++;
}
Expand Down
9 changes: 0 additions & 9 deletions src/graphics/RasterDrawMethods.h
Expand Up @@ -59,13 +59,4 @@ struct RasterDrawMethods
static String::const_iterator TextFit(String const &, int width);

void Clear();

[[deprecated("Use DrawPixel/BlendPixel")]]
void blendpixel(int x, int y, int r, int g, int b, int a);
[[deprecated("Use DrawLine/BlendLine")]]
void draw_line(int x1, int y1, int x2, int y2, int r, int g, int b, int a);
[[deprecated("Use DrawRect/BlendRect")]]
void drawrect(int x, int y, int w, int h, int r, int g, int b, int a);
[[deprecated("Use DrawFilledRect/BlendFilledRect")]]
void fillrect(int x, int y, int w, int h, int r, int g, int b, int a);
};
36 changes: 0 additions & 36 deletions src/graphics/RasterDrawMethodsImpl.h
Expand Up @@ -400,40 +400,4 @@ String::const_iterator RasterDrawMethods<Derived>::TextFit(String const &str, in
return str.end();
}

template<typename Derived>
void RasterDrawMethods<Derived>::blendpixel(int x, int y, int r, int g, int b, int a)
{
if (a == 0xFF)
DrawPixel(Vec2(x, y), RGB<uint8_t>(r, g, b));
else
BlendPixel(Vec2(x, y), RGBA<uint8_t>(r, g, b, a));
}

template<typename Derived>
void RasterDrawMethods<Derived>::draw_line(int x1, int y1, int x2, int y2, int r, int g, int b, int a)
{
if (a == 0xFF)
DrawLine(Vec2(x1, y1), Vec2(x2, y2), RGB<uint8_t>(r, g, b));
else
BlendLine(Vec2(x1, y1), Vec2(x2, y2), RGBA<uint8_t>(r, g, b, a));
}

template<typename Derived>
void RasterDrawMethods<Derived>::drawrect(int x, int y, int w, int h, int r, int g, int b, int a)
{
if (a == 0xFF)
DrawRect(RectSized(Vec2(x, y), Vec2(w, h)), RGB<uint8_t>(r, g, b));
else
BlendRect(RectSized(Vec2(x, y), Vec2(w, h)), RGBA<uint8_t>(r, g, b, a));
}

template<typename Derived>
void RasterDrawMethods<Derived>::fillrect(int x, int y, int w, int h, int r, int g, int b, int a)
{
if (a == 0xFF)
DrawFilledRect(RectSized(Vec2(x, y), Vec2(w, h)), RGB<uint8_t>(r, g, b));
else
BlendFilledRect(RectSized(Vec2(x, y), Vec2(w, h)), RGBA<uint8_t>(r, g, b, a));
}

#undef clipRect

0 comments on commit 410dc71

Please sign in to comment.