From 9fbb780728884584105dc8fe048e5b1a0507592f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Sun, 30 Apr 2023 11:27:58 +0200 Subject: [PATCH] Fix some deprecation warnings Namely: - [[deprecated("Use BlendChar")]] - [[deprecated("Use AddChar")]] - [[deprecated("Use XorPixel")]] - [[deprecated("Use AddPixel")]] - [[deprecated("Use XorLine")]] - [[deprecated("Use XorDottedRect")]] - [[deprecated("Use XorImage")]] - [[deprecated("Use BlendEllipse")]] - [[deprecated("Use BlendFilledEllipse")]] - [[deprecated("Use DrawFilledRect (beware off by 1)")]] --- src/debug/DebugParts.cpp | 14 +- src/graphics/Graphics.cpp | 182 +++++++++--------- src/graphics/RasterDrawMethods.h | 20 -- src/graphics/RasterDrawMethodsImpl.h | 66 ------- src/graphics/Renderer.cpp | 69 ++++--- src/graphics/RendererBasic.cpp | 11 +- src/gui/colourpicker/ColourPickerActivity.cpp | 20 +- src/gui/dialogues/ConfirmPrompt.cpp | 2 +- src/gui/dialogues/ErrorMessage.cpp | 2 +- src/gui/dialogues/InformationMessage.cpp | 2 +- src/gui/dialogues/SaveIDMessage.cpp | 2 +- src/gui/dialogues/TextPrompt.cpp | 2 +- .../elementsearch/ElementSearchActivity.cpp | 2 +- src/gui/filebrowser/FileBrowserActivity.cpp | 2 +- src/gui/game/Brush.cpp | 30 +-- src/gui/game/GOLTool.cpp | 2 +- src/gui/game/GameView.cpp | 13 +- src/gui/game/PropertyTool.cpp | 2 +- src/gui/game/SignTool.cpp | 4 +- src/gui/interface/DirectionSelector.cpp | 8 +- src/gui/interface/DropDown.cpp | 4 +- src/gui/interface/SaveButton.cpp | 4 +- src/gui/login/LoginView.cpp | 2 +- src/gui/options/OptionsView.cpp | 4 +- src/gui/preview/PreviewView.cpp | 2 +- src/gui/profile/ProfileActivity.cpp | 2 +- src/gui/render/RenderView.cpp | 2 +- src/gui/tags/TagsView.cpp | 2 +- src/lua/LuaScriptInterface.cpp | 4 +- src/lua/LuaWindow.cpp | 2 +- src/tasks/TaskWindow.cpp | 2 +- 31 files changed, 201 insertions(+), 284 deletions(-) diff --git a/src/debug/DebugParts.cpp b/src/debug/DebugParts.cpp index f6b9bb262..6a6cba580 100644 --- a/src/debug/DebugParts.cpp +++ b/src/debug/DebugParts.cpp @@ -22,9 +22,9 @@ void DebugParts::Draw() for (int i = 0; i < NPART; i++) { if (sim->parts[i].type) - g->addpixel(x, y, 255, 255, 255, 180); + g->AddPixel({ x, y }, RGBA(255, 255, 255, 180)); else - g->addpixel(x, y, 0, 0, 0, 180); + g->AddPixel({ x, y }, RGBA(0, 0, 0, 180)); if (i == sim->parts_lastActiveIndex) { @@ -40,12 +40,12 @@ void DebugParts::Draw() } g->draw_line(0, lpy, XRES, lpy, 0, 255, 120, 255); g->draw_line(lpx, 0, lpx, YRES, 0, 255, 120, 255); - g->addpixel(lpx, lpy, 255, 50, 50, 220); + g->AddPixel({ lpx, lpy }, RGBA(255, 50, 50, 220)); - g->addpixel(lpx+1, lpy, 255, 50, 50, 120); - g->addpixel(lpx-1, lpy, 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+1, lpy }, RGBA(255, 50, 50, 120)); + g->AddPixel({ lpx-1, lpy }, RGBA(255, 50, 50, 120)); + g->AddPixel({ lpx, lpy+1 }, RGBA(255, 50, 50, 120)); + g->AddPixel({ lpx, lpy-1 }, RGBA(255, 50, 50, 120)); g->fillrect(7, YRES-26, g->TextSize(info).X + 4, 14, 0, 0, 0, 180); g->BlendText({ 10, YRES-22 }, info, RGBA(255, 255, 255, 255)); diff --git a/src/graphics/Graphics.cpp b/src/graphics/Graphics.cpp index b9aa22c2c..1622a0a91 100644 --- a/src/graphics/Graphics.cpp +++ b/src/graphics/Graphics.cpp @@ -174,269 +174,269 @@ void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool inve { case IconOpen: if(invert) - drawchar(x, y, 0xE001, 0, 0, 0, alpha); + BlendChar({ x, y }, 0xE001, RGBA(0, 0, 0, alpha)); else - drawchar(x, y, 0xE001, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE001, RGBA(255, 255, 255, alpha)); break; case IconReload: if(invert) - drawchar(x, y, 0xE011, 0, 0, 0, alpha); + BlendChar({ x, y }, 0xE011, RGBA(0, 0, 0, alpha)); else - drawchar(x, y, 0xE011, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE011, RGBA(255, 255, 255, alpha)); break; case IconSave: if(invert) - drawchar(x, y, 0xE002, 0, 0, 0, alpha); + BlendChar({ x, y }, 0xE002, RGBA(0, 0, 0, alpha)); else - drawchar(x, y, 0xE002, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE002, RGBA(255, 255, 255, alpha)); break; case IconVoteUp: if(invert) { - drawchar(x-11, y+1, 0xE04B, 0, 100, 0, alpha); + BlendChar({ x-11, y+1 }, 0xE04B, RGBA(0, 100, 0, alpha)); BlendText({ x+2, y+1 }, "Vote", RGBA(0, 100, 0, alpha)); } else { - drawchar(x-11, y+1, 0xE04B, 0, 187, 18, alpha); + BlendChar({ x-11, y+1 }, 0xE04B, RGBA(0, 187, 18, alpha)); BlendText({ x+2, y+1 }, "Vote", RGBA(0, 187, 18, alpha)); } break; case IconVoteDown: if(invert) - drawchar(x, y, 0xE04A, 100, 10, 0, alpha); + BlendChar({ x, y }, 0xE04A, RGBA(100, 10, 0, alpha)); else - drawchar(x, y, 0xE04A, 187, 40, 0, alpha); + BlendChar({ x, y }, 0xE04A, RGBA(187, 40, 0, alpha)); break; case IconTag: if(invert) - drawchar(x, y, 0xE003, 0, 0, 0, alpha); + BlendChar({ x, y }, 0xE003, RGBA(0, 0, 0, alpha)); else - drawchar(x, y, 0xE003, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE003, RGBA(255, 255, 255, alpha)); break; case IconNew: if(invert) - drawchar(x, y, 0xE012, 0, 0, 0, alpha); + BlendChar({ x, y }, 0xE012, RGBA(0, 0, 0, alpha)); else - drawchar(x, y, 0xE012, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE012, RGBA(255, 255, 255, alpha)); break; case IconLogin: if(invert) - drawchar(x, y+1, 0xE004, 0, 0, 0, alpha); + BlendChar({ x, y + 1 }, 0xE004, RGBA(0, 0, 0, alpha)); else - drawchar(x, y+1, 0xE004, 255, 255, 255, alpha); + BlendChar({ x, y + 1 }, 0xE004, RGBA(255, 255, 255, alpha)); break; case IconSimulationSettings: if(invert) - drawchar(x, y+1, 0xE04F, 0, 0, 0, alpha); + BlendChar({ x, y + 1 }, 0xE04F, RGBA(0, 0, 0, alpha)); else - drawchar(x, y+1, 0xE04F, 255, 255, 255, alpha); + BlendChar({ x, y + 1 }, 0xE04F, RGBA(255, 255, 255, alpha)); break; case IconRenderSettings: if(invert) { - drawchar(x, y+1, 0xE058, 255, 0, 0, alpha); - drawchar(x, y+1, 0xE059, 0, 255, 0, alpha); - drawchar(x, y+1, 0xE05A, 0, 0, 255, alpha); + BlendChar({ x, y + 1 }, 0xE058, RGBA(255, 0, 0, alpha)); + BlendChar({ x, y + 1 }, 0xE059, RGBA(0, 255, 0, alpha)); + BlendChar({ x, y + 1 }, 0xE05A, RGBA(0, 0, 255, alpha)); } else { - addchar(x, y+1, 0xE058, 255, 0, 0, alpha); - addchar(x, y+1, 0xE059, 0, 255, 0, alpha); - addchar(x, y+1, 0xE05A, 0, 0, 255, alpha); + AddChar({ x, y + 1 }, 0xE058, RGBA(255, 0, 0, alpha)); + AddChar({ x, y + 1 }, 0xE059, RGBA(0, 255, 0, alpha)); + AddChar({ x, y + 1 }, 0xE05A, RGBA(0, 0, 255, alpha)); } break; case IconPause: if(invert) - drawchar(x, y, 0xE010, 0, 0, 0, alpha); + BlendChar({ x, y }, 0xE010, RGBA(0, 0, 0, alpha)); else - drawchar(x, y, 0xE010, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE010, RGBA(255, 255, 255, alpha)); break; case IconFavourite: if(invert) - drawchar(x, y, 0xE04C, 100, 80, 32, alpha); + BlendChar({ x, y }, 0xE04C, RGBA(100, 80, 32, alpha)); else - drawchar(x, y, 0xE04C, 192, 160, 64, alpha); + BlendChar({ x, y }, 0xE04C, RGBA(192, 160, 64, alpha)); break; case IconReport: if(invert) - drawchar(x, y, 0xE063, 140, 140, 0, alpha); + BlendChar({ x, y }, 0xE063, RGBA(140, 140, 0, alpha)); else - drawchar(x, y, 0xE063, 255, 255, 0, alpha); + BlendChar({ x, y }, 0xE063, RGBA(255, 255, 0, alpha)); break; case IconUsername: if(invert) { - drawchar(x, y, 0xE00B, 32, 64, 128, alpha); - drawchar(x, y, 0xE00A, 0, 0, 0, alpha); + BlendChar({ x, y }, 0xE00B, RGBA(32, 64, 128, alpha)); + BlendChar({ x, y }, 0xE00A, RGBA(0, 0, 0, alpha)); } else { - drawchar(x, y, 0xE00B, 32, 64, 128, alpha); - drawchar(x, y, 0xE00A, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE00B, RGBA(32, 64, 128, alpha)); + BlendChar({ x, y }, 0xE00A, RGBA(255, 255, 255, alpha)); } break; case IconPassword: if(invert) { - drawchar(x, y, 0xE00C, 160, 144, 32, alpha); - drawchar(x, y, 0xE004, 0, 0, 0, alpha); + BlendChar({ x, y }, 0xE00C, RGBA(160, 144, 32, alpha)); + BlendChar({ x, y }, 0xE004, RGBA(0, 0, 0, alpha)); } else { - drawchar(x, y, 0xE00C, 160, 144, 32, alpha); - drawchar(x, y, 0xE004, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE00C, RGBA(160, 144, 32, alpha)); + BlendChar({ x, y }, 0xE004, RGBA(255, 255, 255, alpha)); } break; case IconClose: if(invert) - drawchar(x, y, 0xE02A, 20, 20, 20, alpha); + BlendChar({ x, y }, 0xE02A, RGBA(20, 20, 20, alpha)); else - drawchar(x, y, 0xE02A, 230, 230, 230, alpha); + BlendChar({ x, y }, 0xE02A, RGBA(230, 230, 230, alpha)); break; case IconVoteSort: if (invert) { - drawchar(x, y, 0xE029, 44, 48, 32, alpha); - drawchar(x, y, 0xE028, 32, 44, 32, alpha); - drawchar(x, y, 0xE027, 128, 128, 128, alpha); + BlendChar({ x, y }, 0xE029, RGBA(44, 48, 32, alpha)); + BlendChar({ x, y }, 0xE028, RGBA(32, 44, 32, alpha)); + BlendChar({ x, y }, 0xE027, RGBA(128, 128, 128, alpha)); } else { - drawchar(x, y, 0xE029, 144, 48, 32, alpha); - drawchar(x, y, 0xE028, 32, 144, 32, alpha); - drawchar(x, y, 0xE027, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE029, RGBA(144, 48, 32, alpha)); + BlendChar({ x, y }, 0xE028, RGBA(32, 144, 32, alpha)); + BlendChar({ x, y }, 0xE027, RGBA(255, 255, 255, alpha)); } break; case IconDateSort: if (invert) { - drawchar(x, y, 0xE026, 32, 32, 32, alpha); + BlendChar({ x, y }, 0xE026, RGBA(32, 32, 32, alpha)); } else { - drawchar(x, y, 0xE026, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE026, RGBA(255, 255, 255, alpha)); } break; case IconMyOwn: if (invert) { - drawchar(x, y, 0xE014, 192, 160, 64, alpha); - drawchar(x, y, 0xE013, 32, 32, 32, alpha); + BlendChar({ x, y }, 0xE014, RGBA(192, 160, 64, alpha)); + BlendChar({ x, y }, 0xE013, RGBA(32, 32, 32, alpha)); } else { - drawchar(x, y, 0xE014, 192, 160, 64, alpha); - drawchar(x, y, 0xE013, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE014, RGBA(192, 160, 64, alpha)); + BlendChar({ x, y }, 0xE013, RGBA(255, 255, 255, alpha)); } break; case IconSearch: - drawchar(x, y, 0xE00E, 30, 30, 180, alpha); - drawchar(x, y, 0xE00F, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE00E, RGBA(30, 30, 180, alpha)); + BlendChar({ x, y }, 0xE00F, RGBA(255, 255, 255, alpha)); break; case IconDelete: if(invert) { - drawchar(x, y, 0xE006, 159, 47, 31, alpha); - drawchar(x, y, 0xE005, 0, 0, 0, alpha); + BlendChar({ x, y }, 0xE006, RGBA(159, 47, 31, alpha)); + BlendChar({ x, y }, 0xE005, RGBA(0, 0, 0, alpha)); } else { - drawchar(x, y, 0xE006, 159, 47, 31, alpha); - drawchar(x, y, 0xE005, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE006, RGBA(159, 47, 31, alpha)); + BlendChar({ x, y }, 0xE005, RGBA(255, 255, 255, alpha)); } break; case IconAdd: if(invert) { - drawchar(x, y, 0xE006, 32, 144, 32, alpha); - drawchar(x, y, 0xE009, 0, 0, 0, alpha); + BlendChar({ x, y }, 0xE006, RGBA(32, 144, 32, alpha)); + BlendChar({ x, y }, 0xE009, RGBA(0, 0, 0, alpha)); } else { - drawchar(x, y, 0xE006, 32, 144, 32, alpha); - drawchar(x, y, 0xE009, 255, 255, 255, alpha); + BlendChar({ x, y }, 0xE006, RGBA(32, 144, 32, alpha)); + BlendChar({ x, y }, 0xE009, RGBA(255, 255, 255, alpha)); } break; case IconVelocity: - drawchar(x+1, y, 0xE018, 128, 160, 255, alpha); + BlendChar({ x + 1, y }, 0xE018, RGBA(128, 160, 255, alpha)); break; case IconPressure: if(invert) - drawchar(x+1, y+1, 0xE019, 180, 160, 16, alpha); + BlendChar({ x + 1, y + 1 }, 0xE019, RGBA(180, 160, 16, alpha)); else - drawchar(x+1, y+1, 0xE019, 255, 212, 32, alpha); + BlendChar({ x + 1, y + 1 }, 0xE019, RGBA(255, 212, 32, alpha)); break; case IconPersistant: if(invert) - drawchar(x+1, y+1, 0xE01A, 20, 20, 20, alpha); + BlendChar({ x + 1, y + 1 }, 0xE01A, RGBA(20, 20, 20, alpha)); else - drawchar(x+1, y+1, 0xE01A, 212, 212, 212, alpha); + BlendChar({ x + 1, y + 1 }, 0xE01A, RGBA(212, 212, 212, alpha)); break; case IconFire: - drawchar(x+1, y+1, 0xE01B, 255, 0, 0, alpha); - drawchar(x+1, y+1, 0xE01C, 255, 255, 64, alpha); + BlendChar({ x + 1, y + 1 }, 0xE01B, RGBA(255, 0, 0, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE01C, RGBA(255, 255, 64, alpha)); break; case IconBlob: if(invert) - drawchar(x+1, y, 0xE03F, 55, 180, 55, alpha); + BlendChar({ x + 1, y }, 0xE03F, RGBA(55, 180, 55, alpha)); else - drawchar(x+1, y, 0xE03F, 55, 255, 55, alpha); + BlendChar({ x + 1, y }, 0xE03F, RGBA(55, 255, 55, alpha)); break; case IconHeat: - drawchar(x+3, y, 0xE03E, 255, 0, 0, alpha); + BlendChar({ x + 3, y }, 0xE03E, RGBA(255, 0, 0, alpha)); if(invert) - drawchar(x+3, y, 0xE03D, 0, 0, 0, alpha); + BlendChar({ x + 3, y }, 0xE03D, RGBA(0, 0, 0, alpha)); else - drawchar(x+3, y, 0xE03D, 255, 255, 255, alpha); + BlendChar({ x + 3, y }, 0xE03D, RGBA(255, 255, 255, alpha)); break; case IconBlur: if(invert) - drawchar(x+1, y, 0xE044, 50, 70, 180, alpha); + BlendChar({ x + 1, y }, 0xE044, RGBA(50, 70, 180, alpha)); else - drawchar(x+1, y, 0xE044, 100, 150, 255, alpha); + BlendChar({ x + 1, y }, 0xE044, RGBA(100, 150, 255, alpha)); break; case IconGradient: if(invert) - drawchar(x+1, y+1, 0xE053, 255, 50, 255, alpha); + BlendChar({ x + 1, y + 1 }, 0xE053, RGBA(255, 50, 255, alpha)); else - drawchar(x+1, y+1, 0xE053, 205, 50, 205, alpha); + BlendChar({ x + 1, y + 1 }, 0xE053, RGBA(205, 50, 205, alpha)); break; case IconLife: if(invert) - drawchar(x, y+1, 0xE060, 0, 0, 0, alpha); + BlendChar({ x, y + 1 }, 0xE060, RGBA(0, 0, 0, alpha)); else - drawchar(x, y+1, 0xE060, 255, 255, 255, alpha); + BlendChar({ x, y + 1 }, 0xE060, RGBA(255, 255, 255, alpha)); break; case IconEffect: - drawchar(x+1, y, 0xE061, 255, 255, 160, alpha); + BlendChar({ x + 1, y }, 0xE061, RGBA(255, 255, 160, alpha)); break; case IconGlow: - drawchar(x+1, y, 0xE05F, 200, 255, 255, alpha); + BlendChar({ x + 1, y }, 0xE05F, RGBA(200, 255, 255, alpha)); break; case IconWarp: - drawchar(x+1, y, 0xE05E, 255, 255, 255, alpha); + BlendChar({ x + 1, y }, 0xE05E, RGBA(255, 255, 255, alpha)); break; case IconBasic: if(invert) - drawchar(x+1, y+1, 0xE05B, 50, 50, 0, alpha); + BlendChar({ x + 1, y + 1 }, 0xE05B, RGBA(50, 50, 0, alpha)); else - drawchar(x+1, y+1, 0xE05B, 255, 255, 200, alpha); + BlendChar({ x + 1, y + 1 }, 0xE05B, RGBA(255, 255, 200, alpha)); break; case IconAltAir: if(invert) { - drawchar(x+1, y+1, 0xE054, 180, 55, 55, alpha); - drawchar(x+1, y+1, 0xE055, 55, 180, 55, alpha); + BlendChar({ x + 1, y + 1 }, 0xE054, RGBA(180, 55, 55, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE055, RGBA(55, 180, 55, alpha)); } else { - drawchar(x+1, y+1, 0xE054, 255, 55, 55, alpha); - drawchar(x+1, y+1, 0xE055, 55, 255, 55, alpha); + BlendChar({ x + 1, y + 1 }, 0xE054, RGBA(255, 55, 55, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE055, RGBA(55, 255, 55, alpha)); } break; default: if(invert) - drawchar(x, y, 't', 0, 0, 0, alpha); + BlendChar({ x, y }, 't', RGBA(0, 0, 0, alpha)); else - drawchar(x, y, 't', 255, 255, 255, alpha); + BlendChar({ x, y }, 't', RGBA(255, 255, 255, alpha)); break; } } diff --git a/src/graphics/RasterDrawMethods.h b/src/graphics/RasterDrawMethods.h index 53a93e042..9fd8051ba 100644 --- a/src/graphics/RasterDrawMethods.h +++ b/src/graphics/RasterDrawMethods.h @@ -60,32 +60,12 @@ struct RasterDrawMethods void Clear(); - [[deprecated("Use BlendChar")]] - int drawchar(int x, int y, String::value_type, int r, int g, int b, int a); - [[deprecated("Use AddChar")]] - int addchar(int x, int y, String::value_type, int r, int g, int b, int a); - [[deprecated("Use XorPixel")]] - void xor_pixel(int x, int y); [[deprecated("Use DrawPixel/BlendPixel")]] void blendpixel(int x, int y, int r, int g, int b, int a); - [[deprecated("Use AddPixel")]] - void addpixel(int x, int y, int r, int g, int b, int a); - [[deprecated("Use XorLine")]] - void xor_line(int x1, int y1, int x2, int y2); - [[deprecated("Use XorDottedRect")]] - void xor_rect(int x, int y, int w, int h); - [[deprecated("Use XorImage")]] - void xor_bitmap(unsigned char *bitmap, int x, int y, int w, int h); [[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); - [[deprecated("Use BlendEllipse")]] - void drawcircle(int x, int y, int rx, int ry, int r, int g, int b, int a); - [[deprecated("Use BlendFilledEllipse")]] - 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)")]] - void clearrect(int x, int y, int w, int h); }; diff --git a/src/graphics/RasterDrawMethodsImpl.h b/src/graphics/RasterDrawMethodsImpl.h index 42d6d43d7..c3685f9d4 100644 --- a/src/graphics/RasterDrawMethodsImpl.h +++ b/src/graphics/RasterDrawMethodsImpl.h @@ -5,7 +5,6 @@ #include "Graphics.h" #include "RasterDrawMethods.h" -#define video() (static_cast(*this).video) #define clipRect() (static_cast(*this).getClipRect()) template @@ -401,28 +400,6 @@ String::const_iterator RasterDrawMethods::TextFit(String const &str, in return str.end(); } -template -int RasterDrawMethods::drawchar(int x, int y, String::value_type c, int r, int g, int b, int a) -{ - return x + BlendChar(Vec2(x, y), c, RGBA(r, g, b, a)); -} - -template -int RasterDrawMethods::addchar(int x, int y, String::value_type c, int r, int g, int b, int a) -{ - FontReader reader(c); - for (int j = -2; j < FONT_H - 2; j++) - for (int i = 0; i < reader.GetWidth(); i++) - addpixel(x + i, y + j, r, g, b, reader.NextPixel() * a / 3); - return x + reader.GetWidth(); -} - -template -void RasterDrawMethods::xor_pixel(int x, int y) -{ - XorPixel(Vec2(x, y)); -} - template void RasterDrawMethods::blendpixel(int x, int y, int r, int g, int b, int a) { @@ -432,30 +409,6 @@ void RasterDrawMethods::blendpixel(int x, int y, int r, int g, int b, i BlendPixel(Vec2(x, y), RGBA(r, g, b, a)); } -template -void RasterDrawMethods::addpixel(int x, int y, int r, int g, int b, int a) -{ - AddPixel(Vec2(x, y), RGBA(r, g, b, a)); -} - -template -void RasterDrawMethods::xor_line(int x1, int y1, int x2, int y2) -{ - XorLine(Vec2(x1, y1), Vec2(x2, y2)); -} - -template -void RasterDrawMethods::xor_rect(int x, int y, int w, int h) -{ - XorDottedRect(RectSized(Vec2(x, y), Vec2(w, h))); -} - -template -void RasterDrawMethods::xor_bitmap(unsigned char * bitmap, int x, int y, int w, int h) -{ - XorImage(bitmap, RectSized(Vec2(x, y), Vec2(w, h))); -} - template void RasterDrawMethods::draw_line(int x1, int y1, int x2, int y2, int r, int g, int b, int a) { @@ -483,23 +436,4 @@ void RasterDrawMethods::fillrect(int x, int y, int w, int h, int r, int BlendFilledRect(RectSized(Vec2(x, y), Vec2(w, h)), RGBA(r, g, b, a)); } -template -void RasterDrawMethods::drawcircle(int x, int y, int rx, int ry, int r, int g, int b, int a) -{ - BlendEllipse(Vec2(x, y), Vec2(rx, ry), RGBA(r, g, b, a)); -} - -template -void RasterDrawMethods::fillcircle(int x, int y, int rx, int ry, int r, int g, int b, int a) -{ - BlendFilledEllipse(Vec2(x, y), Vec2(rx, ry), RGBA(r, g, b, a)); -} - -template -void RasterDrawMethods::clearrect(int x, int y, int w, int h) -{ - DrawFilledRect(RectSized(Vec2(x + 1, y + 1), Vec2(w - 1, h - 1)), 0x000000_rgb); -} - -#undef video #undef clipRect diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index 34134290d..5623dbc6b 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -150,7 +150,7 @@ void Renderer::DrawSigns() if (currentSign.text.length()) { String text = currentSign.getDisplayText(sim, x, y, w, h); - clearrect(x, y, w+1, h); + DrawFilledRect(RectSized(Vec2{ x + 1, y + 1 }, Vec2{ w, h - 1 }), 0x000000_rgb); drawrect(x, y, w+1, h, 192, 192, 192, 255); BlendText({ x+3, y+4 }, text, RGBA(255, 255, 255, 255)); @@ -535,7 +535,7 @@ void Renderer::render_parts() } if(pixel_mode & PMODE_ADD) { - addpixel(nx, ny, colr, colg, colb, cola); + AddPixel({ nx, ny }, RGBA(colr, colg, colb, cola)); } if(pixel_mode & PMODE_BLOB) { @@ -554,24 +554,24 @@ void Renderer::render_parts() if(pixel_mode & PMODE_GLOW) { int cola1 = (5*cola)/255; - addpixel(nx, ny, colr, colg, colb, (192*cola)/255); - addpixel(nx+1, ny, colr, colg, colb, (96*cola)/255); - addpixel(nx-1, ny, colr, colg, colb, (96*cola)/255); - addpixel(nx, ny+1, colr, colg, colb, (96*cola)/255); - addpixel(nx, ny-1, colr, colg, colb, (96*cola)/255); + AddPixel({ nx, ny }, RGBA(colr, colg, colb, (192*cola)/255)); + AddPixel({ nx+1, ny }, RGBA(colr, colg, colb, (96*cola)/255)); + AddPixel({ nx-1, ny }, RGBA(colr, colg, colb, (96*cola)/255)); + AddPixel({ nx, ny+1 }, RGBA(colr, colg, colb, (96*cola)/255)); + AddPixel({ nx, ny-1 }, RGBA(colr, colg, colb, (96*cola)/255)); for (x = 1; x < 6; x++) { - addpixel(nx, ny-x, colr, colg, colb, cola1); - addpixel(nx, ny+x, colr, colg, colb, cola1); - addpixel(nx-x, ny, colr, colg, colb, cola1); - addpixel(nx+x, ny, colr, colg, colb, cola1); + AddPixel({ nx, ny-x }, RGBA(colr, colg, colb, cola1)); + AddPixel({ nx, ny+x }, RGBA(colr, colg, colb, cola1)); + AddPixel({ nx-x, ny }, RGBA(colr, colg, colb, cola1)); + AddPixel({ nx+x, ny }, RGBA(colr, colg, colb, cola1)); for (y = 1; y < 6; y++) { if(x + y > 7) continue; - addpixel(nx+x, ny-y, colr, colg, colb, cola1); - addpixel(nx-x, ny+y, colr, colg, colb, cola1); - addpixel(nx+x, ny+y, colr, colg, colb, cola1); - addpixel(nx-x, ny-y, colr, colg, colb, cola1); + AddPixel({ nx+x, ny-y }, RGBA(colr, colg, colb, cola1)); + AddPixel({ nx-x, ny+y }, RGBA(colr, colg, colb, cola1)); + AddPixel({ nx+x, ny+y }, RGBA(colr, colg, colb, cola1)); + AddPixel({ nx-x, ny-y }, RGBA(colr, colg, colb, cola1)); } } } @@ -595,11 +595,10 @@ void Renderer::render_parts() flicker = float(rng()%20); gradv = 4*sim->parts[i].life + flicker; for (x = 0; gradv>0.5; x++) { - addpixel(nx+x, ny, colr, colg, colb, int(gradv)); - addpixel(nx-x, ny, colr, colg, colb, int(gradv)); - - addpixel(nx, ny+x, colr, colg, colb, int(gradv)); - addpixel(nx, ny-x, colr, colg, colb, int(gradv)); + AddPixel({ nx+x, ny }, RGBA(colr, colg, colb, int(gradv))); + AddPixel({ nx-x, ny }, RGBA(colr, colg, colb, int(gradv))); + AddPixel({ nx, ny+x }, RGBA(colr, colg, colb, int(gradv))); + AddPixel({ nx, ny-x }, RGBA(colr, colg, colb, int(gradv))); gradv = gradv/1.5f; } } @@ -618,10 +617,10 @@ void Renderer::render_parts() blendpixel(nx+1, ny+1, colr, colg, colb, int(gradv)); blendpixel(nx-1, ny+1, colr, colg, colb, int(gradv)); for (x = 1; gradv>0.5; x++) { - addpixel(nx+x, ny, colr, colg, colb, int(gradv)); - addpixel(nx-x, ny, colr, colg, colb, int(gradv)); - addpixel(nx, ny+x, colr, colg, colb, int(gradv)); - addpixel(nx, ny-x, colr, colg, colb, int(gradv)); + AddPixel({ nx+x, ny }, RGBA(colr, colg, colb, int(gradv))); + AddPixel({ nx-x, ny }, RGBA(colr, colg, colb, int(gradv))); + AddPixel({ nx, ny+x }, RGBA(colr, colg, colb, int(gradv))); + AddPixel({ nx, ny-x }, RGBA(colr, colg, colb, int(gradv))); gradv = gradv/1.2f; } } @@ -640,10 +639,10 @@ void Renderer::render_parts() blendpixel(nx+1, ny+1, colr, colg, colb, int(gradv)); blendpixel(nx-1, ny+1, colr, colg, colb, int(gradv)); for (x = 1; gradv>0.5; x++) { - addpixel(nx+x, ny, colr, colg, colb, int(gradv)); - addpixel(nx-x, ny, colr, colg, colb, int(gradv)); - addpixel(nx, ny+x, colr, colg, colb, int(gradv)); - addpixel(nx, ny-x, colr, colg, colb, int(gradv)); + AddPixel({ nx+x, ny }, RGBA(colr, colg, colb, int(gradv))); + AddPixel({ nx-x, ny }, RGBA(colr, colg, colb, int(gradv))); + AddPixel({ nx, ny+x }, RGBA(colr, colg, colb, int(gradv))); + AddPixel({ nx, ny-x }, RGBA(colr, colg, colb, int(gradv))); gradv = gradv/1.01f; } } @@ -661,7 +660,7 @@ void Renderer::render_parts() nxo = (int)(ddist*cos(drad)); nyo = (int)(ddist*sin(drad)); if (ny+nyo>0 && ny+nyo0 && nx+nxopmap[ny+nyo][nx+nxo]) != PT_PRTI) - addpixel(nx+nxo, ny+nyo, colr, colg, colb, 255-orbd[r]); + AddPixel({ nx+nxo, ny+nyo }, RGBA(colr, colg, colb, 255-orbd[r])); } } if (pixel_mode & EFFECT_GRAVOUT) @@ -678,7 +677,7 @@ void Renderer::render_parts() nxo = (int)(ddist*cos(drad)); nyo = (int)(ddist*sin(drad)); if (ny+nyo>0 && ny+nyo0 && nx+nxopmap[ny+nyo][nx+nxo]) != PT_PRTO) - addpixel(nx+nxo, ny+nyo, colr, colg, colb, 255-orbd[r]); + AddPixel({ nx+nxo, ny+nyo }, RGBA(colr, colg, colb, 255-orbd[r])); } } if (pixel_mode & EFFECT_DBGLINES && !(display_mode&DISPLAY_PERS)) @@ -697,7 +696,7 @@ void Renderer::render_parts() { othertmp = (int)((parts[z].temp-73.15f)/100+1); if (tmp == othertmp) - xor_line(nx,ny,(int)(parts[z].x+0.5f),(int)(parts[z].y+0.5f)); + XorLine({ nx, ny }, Vec2{ int(parts[z].x+0.5f), int(parts[z].y+0.5f) }); } } } @@ -809,7 +808,7 @@ void Renderer::draw_grav() { nx -= sim->gravx[ca]*0.5f; ny -= sim->gravy[ca]*0.5f; - addpixel((int)(nx+0.5f), (int)(ny+0.5f), 255, 255, 255, (int)(dist*20.0f)); + AddPixel({ int(nx+0.5f), int(ny+0.5f) }, RGBA(255, 255, 255, (int)(dist*20.0f))); } } } @@ -981,7 +980,7 @@ void Renderer::DrawWalls() if (!xVel && !yVel) { BlendText({ x*CELL, y*CELL-2 }, 0xE00D, RGBA(255, 255, 255, 128)); - addpixel(oldX, oldY, 255, 255, 255, 255); + AddPixel({ oldX, oldY }, RGBA(255, 255, 255, 255)); continue; } bool changed = false; @@ -997,7 +996,7 @@ void Renderer::DrawWalls() } if (changed && (newX<0 || newX>=XRES || newY<0 || newY>=YRES)) break; - addpixel(newX, newY, 255, 255, 255, 64); + AddPixel({ newX, newY }, RGBA(255, 255, 255, 64)); // cache velocity and other checks so we aren't running them constantly if (changed) { @@ -1165,7 +1164,7 @@ void Renderer::render_fire() a = fire_alpha[y+CELL][x+CELL]; if (findingElement) a /= 2; - addpixel(i*CELL+x, j*CELL+y, r, g, b, a); + AddPixel({ i*CELL+x, j*CELL+y }, RGBA(r, g, b, a)); } r *= 8; g *= 8; diff --git a/src/graphics/RendererBasic.cpp b/src/graphics/RendererBasic.cpp index 605c68d54..951e903a1 100644 --- a/src/graphics/RendererBasic.cpp +++ b/src/graphics/RendererBasic.cpp @@ -69,7 +69,8 @@ void Renderer::RenderZoom() { int x, y, i, j; pixel pix; - clearrect(zoomWindowPosition.X-1, zoomWindowPosition.Y-1, zoomScopeSize*ZFACTOR+1, zoomScopeSize*ZFACTOR+1); + + DrawFilledRect(RectSized(zoomWindowPosition, { zoomScopeSize * ZFACTOR, zoomScopeSize * ZFACTOR }), 0x000000_rgb); drawrect(zoomWindowPosition.X-2, zoomWindowPosition.Y-2, zoomScopeSize*ZFACTOR+3, zoomScopeSize*ZFACTOR+3, 192, 192, 192, 255); drawrect(zoomWindowPosition.X-1, zoomWindowPosition.Y-1, zoomScopeSize*ZFACTOR+1, zoomScopeSize*ZFACTOR+1, 0, 0, 0, 255); for (j=0; jclearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); g->fillrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3, 0, 0, 0, currentAlpha); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); g->drawrect(Position.X+4, Position.Y+4, 258, 130, 180, 180, 180, 255); - int offsetX = Position.X+5; - int offsetY = Position.Y+5; + auto offset = Position + Vec2{ 5, 5 }; //draw color square @@ -272,7 +270,7 @@ void ColourPickerActivity::OnDraw() { for(int hue = 0; hue <= 359; hue++) { - currx = clamp_flt(float(hue), 0, 359)+offsetX; + currx = clamp_flt(float(hue), 0, 359)+offset.X; if (currx == lastx) continue; lastx = currx; @@ -280,7 +278,7 @@ void ColourPickerActivity::OnDraw() int cg = 0; int cb = 0; HSV_to_RGB(hue, 255-saturation, currentValue, &cr, &cg, &cb); - g->blendpixel(currx, (saturation/2)+offsetY, cr, cg, cb, currentAlpha); + g->blendpixel(currx, (saturation/2)+offset.Y, cr, cg, cb, currentAlpha); } } @@ -294,8 +292,8 @@ void ColourPickerActivity::OnDraw() for (int ry = 0; ry < (hSlider->Size.Y / 2) - 1; ry++) { g->blendpixel( - rx + offsetX + hSlider->Position.X, - ry + offsetY + hSlider->Position.Y, + rx + offset.X + hSlider->Position.X, + ry + offset.Y + hSlider->Position.Y, red, green, blue, currentAlpha ); } @@ -304,9 +302,9 @@ void ColourPickerActivity::OnDraw() //draw color square pointer int currentHueX = clamp_flt(float(currentHue), 0, 359); int currentSaturationY = ((255-currentSaturation)/2); - g->xor_line(offsetX+currentHueX, offsetY+currentSaturationY-5, offsetX+currentHueX, offsetY+currentSaturationY-1); - g->xor_line(offsetX+currentHueX, offsetY+currentSaturationY+1, offsetX+currentHueX, offsetY+currentSaturationY+5); - g->xor_line(offsetX+currentHueX-5, offsetY+currentSaturationY, offsetX+currentHueX-1, offsetY+currentSaturationY); - g->xor_line(offsetX+currentHueX+1, offsetY+currentSaturationY, offsetX+currentHueX+5, offsetY+currentSaturationY); + g->XorLine(offset + Vec2{ currentHueX, currentSaturationY-5 }, offset + Vec2{ currentHueX, currentSaturationY-1 }); + g->XorLine(offset + Vec2{ currentHueX, currentSaturationY+1 }, offset + Vec2{ currentHueX, currentSaturationY+5 }); + g->XorLine(offset + Vec2{ currentHueX-5, currentSaturationY }, offset + Vec2{ currentHueX-1, currentSaturationY }); + g->XorLine(offset + Vec2{ currentHueX+1, currentSaturationY }, offset + Vec2{ currentHueX+5, currentSaturationY }); } diff --git a/src/gui/dialogues/ConfirmPrompt.cpp b/src/gui/dialogues/ConfirmPrompt.cpp index b13073534..570c6412a 100644 --- a/src/gui/dialogues/ConfirmPrompt.cpp +++ b/src/gui/dialogues/ConfirmPrompt.cpp @@ -82,6 +82,6 @@ void ConfirmPrompt::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); } diff --git a/src/gui/dialogues/ErrorMessage.cpp b/src/gui/dialogues/ErrorMessage.cpp index 824bc5d8c..c420fc9ec 100644 --- a/src/gui/dialogues/ErrorMessage.cpp +++ b/src/gui/dialogues/ErrorMessage.cpp @@ -58,6 +58,6 @@ void ErrorMessage::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); } diff --git a/src/gui/dialogues/InformationMessage.cpp b/src/gui/dialogues/InformationMessage.cpp index b92aa1e54..a949532eb 100644 --- a/src/gui/dialogues/InformationMessage.cpp +++ b/src/gui/dialogues/InformationMessage.cpp @@ -74,6 +74,6 @@ void InformationMessage::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); } diff --git a/src/gui/dialogues/SaveIDMessage.cpp b/src/gui/dialogues/SaveIDMessage.cpp index ff70727b3..cc68f29d5 100644 --- a/src/gui/dialogues/SaveIDMessage.cpp +++ b/src/gui/dialogues/SaveIDMessage.cpp @@ -52,7 +52,7 @@ void SaveIDMessage::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); } diff --git a/src/gui/dialogues/TextPrompt.cpp b/src/gui/dialogues/TextPrompt.cpp index 346ea6d77..e9af7eef2 100644 --- a/src/gui/dialogues/TextPrompt.cpp +++ b/src/gui/dialogues/TextPrompt.cpp @@ -93,6 +93,6 @@ void TextPrompt::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); } diff --git a/src/gui/elementsearch/ElementSearchActivity.cpp b/src/gui/elementsearch/ElementSearchActivity.cpp index 687553563..90574b2d3 100644 --- a/src/gui/elementsearch/ElementSearchActivity.cpp +++ b/src/gui/elementsearch/ElementSearchActivity.cpp @@ -212,7 +212,7 @@ void ElementSearchActivity::SetActiveTool(int selectionState, Tool * tool) void ElementSearchActivity::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); 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); diff --git a/src/gui/filebrowser/FileBrowserActivity.cpp b/src/gui/filebrowser/FileBrowserActivity.cpp index ec1df18fb..2ef5ee079 100644 --- a/src/gui/filebrowser/FileBrowserActivity.cpp +++ b/src/gui/filebrowser/FileBrowserActivity.cpp @@ -303,7 +303,7 @@ void FileBrowserActivity::OnDraw() Graphics * g = GetGraphics(); //Window Background+Outline - g->clearrect(Position.X-2, Position.Y-2, Size.X+4, Size.Y+4); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); } diff --git a/src/gui/game/Brush.cpp b/src/gui/game/Brush.cpp index b9675998a..e73b53f4e 100644 --- a/src/gui/game/Brush.cpp +++ b/src/gui/game/Brush.cpp @@ -100,31 +100,35 @@ void Brush::RenderRect(Renderer * ren, ui::Point position1, ui::Point position2) width *= -1; } - ren->xor_line(position1.X, position1.Y, position1.X+width, position1.Y); - if (height>0){ - ren->xor_line(position1.X, position1.Y+height, position1.X+width, position1.Y+height); - if (height>1){ - ren->xor_line(position1.X+width, position1.Y+1, position1.X+width, position1.Y+height-1); - if (width>0) - ren->xor_line(position1.X, position1.Y+1, position1.X, position1.Y+height-1); + ren->XorLine(position1, position1 + Vec2{ width, 0 }); + if (height > 0) + { + ren->XorLine(position1 + Vec2{ 0, height }, position1 + Vec2{ width, height }); + if (height > 1) + { + ren->XorLine(position1 + Vec2{ width, 1 }, position1 + Vec2{ width, height - 1 }); + if (width > 0) + { + ren->XorLine(position1 + Vec2{ 0, 1 }, position1 + Vec2{ 0, height - 1 }); + } } } } void Brush::RenderLine(Renderer * ren, ui::Point position1, ui::Point position2) const { - ren->xor_line(position1.X, position1.Y, position2.X, position2.Y); + ren->XorLine(position1, position2); } void Brush::RenderPoint(Renderer * ren, ui::Point position) const { - ren->xor_bitmap(&outline[0], position.X - radius.X, position.Y - radius.Y, 2 * radius.X + 1, 2 * radius.Y + 1); + ren->XorImage(&outline[0], RectBetween(position - radius, position + radius)); } void Brush::RenderFill(Renderer * ren, ui::Point position) const { - ren->xor_line(position.X-5, position.Y, position.X-1, position.Y); - ren->xor_line(position.X+5, position.Y, position.X+1, position.Y); - ren->xor_line(position.X, position.Y-5, position.X, position.Y-1); - ren->xor_line(position.X, position.Y+5, position.X, position.Y+1); + ren->XorLine(position - Vec2{ 5, 0 }, position - Vec2{ 1, 0 }); + ren->XorLine(position + Vec2{ 5, 0 }, position + Vec2{ 1, 0 }); + ren->XorLine(position - Vec2{ 0, 5 }, position - Vec2{ 0, 1 }); + ren->XorLine(position + Vec2{ 0, 5 }, position + Vec2{ 0, 1 }); } diff --git a/src/gui/game/GOLTool.cpp b/src/gui/game/GOLTool.cpp index 57347ef1e..187fb1c48 100644 --- a/src/gui/game/GOLTool.cpp +++ b/src/gui/game/GOLTool.cpp @@ -185,7 +185,7 @@ void GOLWindow::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); int width = Size.X - 60; diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 2a2ec165e..eae2cb4b8 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -2108,11 +2108,12 @@ void GameView::OnDraw() if (wallBrush) { ui::Point finalBrushRadius = c->NormaliseBlockCoord(activeBrush->GetRadius()); - ren->xor_line(finalCurrentMouse.X-finalBrushRadius.X, finalCurrentMouse.Y-finalBrushRadius.Y, finalCurrentMouse.X+finalBrushRadius.X+CELL-1, finalCurrentMouse.Y-finalBrushRadius.Y); - ren->xor_line(finalCurrentMouse.X-finalBrushRadius.X, finalCurrentMouse.Y+finalBrushRadius.Y+CELL-1, finalCurrentMouse.X+finalBrushRadius.X+CELL-1, finalCurrentMouse.Y+finalBrushRadius.Y+CELL-1); - - ren->xor_line(finalCurrentMouse.X-finalBrushRadius.X, finalCurrentMouse.Y-finalBrushRadius.Y+1, finalCurrentMouse.X-finalBrushRadius.X, finalCurrentMouse.Y+finalBrushRadius.Y+CELL-2); - ren->xor_line(finalCurrentMouse.X+finalBrushRadius.X+CELL-1, finalCurrentMouse.Y-finalBrushRadius.Y+1, finalCurrentMouse.X+finalBrushRadius.X+CELL-1, finalCurrentMouse.Y+finalBrushRadius.Y+CELL-2); + auto topLeft = finalCurrentMouse - finalBrushRadius; + auto bottomRight = finalCurrentMouse + finalBrushRadius + Vec2{ CELL - 1, CELL - 1 }; + ren->XorLine({ topLeft.X, topLeft.Y }, { bottomRight.X, topLeft.Y }); + ren->XorLine({ topLeft.X, bottomRight.Y }, { bottomRight.X, bottomRight.Y }); + ren->XorLine({ topLeft.X, topLeft.Y + 1 }, { topLeft.X, bottomRight.Y - 1 }); // offset by 1 so the corners don't get xor'd twice + ren->XorLine({ bottomRight.X, topLeft.Y + 1 }, { bottomRight.X, bottomRight.Y - 1 }); // offset by 1 so the corners don't get xor'd twice } else { @@ -2158,7 +2159,7 @@ void GameView::OnDraw() ren->fillrect(0, y1, x1, (y2-y1)+1, 0, 0, 0, 100); ren->fillrect(x2+1, y1, XRES-x2-1, (y2-y1)+1, 0, 0, 0, 100); - ren->xor_rect(x1, y1, (x2-x1)+1, (y2-y1)+1); + ren->XorDottedRect(RectBetween(Vec2{ x1, y1 }, Vec2{ x2, y2 })); } } } diff --git a/src/gui/game/PropertyTool.cpp b/src/gui/game/PropertyTool.cpp index bbd02aab4..9a20af4ee 100644 --- a/src/gui/game/PropertyTool.cpp +++ b/src/gui/game/PropertyTool.cpp @@ -238,7 +238,7 @@ void PropertyWindow::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); } diff --git a/src/gui/game/SignTool.cpp b/src/gui/game/SignTool.cpp index 8f16f7ad9..fe41baa36 100644 --- a/src/gui/game/SignTool.cpp +++ b/src/gui/game/SignTool.cpp @@ -168,7 +168,7 @@ void SignWindow::DoDraw() Graphics * g = GetGraphics(); String text = currentSign.getDisplayText(sim, x, y, w, h); - g->clearrect(x, y, w+1, h); + g->DrawFilledRect(RectSized(Vec2{ x + 1, y + 1 }, Vec2{ w, h - 1 }), 0x000000_rgb); g->drawrect(x, y, w+1, h, 192, 192, 192, 255); g->BlendText({ x+3, y+4 }, text, RGBA(255, 255, 255, 255)); @@ -222,7 +222,7 @@ void SignWindow::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); } diff --git a/src/gui/interface/DirectionSelector.cpp b/src/gui/interface/DirectionSelector.cpp index f00f34408..c261ff8bf 100644 --- a/src/gui/interface/DirectionSelector.cpp +++ b/src/gui/interface/DirectionSelector.cpp @@ -115,8 +115,8 @@ void DirectionSelector::Draw(const ui::Point& screenPos) auto handleTrackRadius = radius + handleRadius; ui::Point center = screenPos + Vec2{ handleTrackRadius, handleTrackRadius }; - g->fillcircle(center.X, center.Y, handleTrackRadius, handleTrackRadius, backgroundColor.Red, backgroundColor.Green, backgroundColor.Blue, backgroundColor.Alpha); - g->drawcircle(center.X, center.Y, handleTrackRadius, handleTrackRadius, borderColor.Red, borderColor.Green, borderColor.Blue, borderColor.Alpha); + g->BlendFilledEllipse(center, { handleTrackRadius, handleTrackRadius }, backgroundColor); + g->BlendEllipse(center, { handleTrackRadius, handleTrackRadius }, borderColor); for (auto &point : snapPoints) { @@ -128,8 +128,8 @@ void DirectionSelector::Draw(const ui::Point& screenPos) ); } - g->fillcircle(center.X + value.offset.X, center.Y + value.offset.Y, handleRadius, handleRadius, foregroundColor.Red, foregroundColor.Green, foregroundColor.Blue, (mouseHover || mouseDown) ? std::min((int)(foregroundColor.Alpha * 1.5f), 255) : foregroundColor.Alpha); - g->drawcircle(center.X + value.offset.X, center.Y + value.offset.Y, handleRadius, handleRadius, borderColor.Red, borderColor.Green, borderColor.Blue, borderColor.Alpha); + g->BlendFilledEllipse(center + value.offset, { handleRadius, handleRadius }, RGBA(foregroundColor.Red, foregroundColor.Green, foregroundColor.Blue, (mouseHover || mouseDown) ? std::min(int(foregroundColor.Alpha * 1.5f), 255) : foregroundColor.Alpha)); + g->BlendEllipse(center + value.offset, { handleRadius, handleRadius }, borderColor); } void DirectionSelector::OnMouseMoved(int x, int y, int dx, int dy) diff --git a/src/gui/interface/DropDown.cpp b/src/gui/interface/DropDown.cpp index 8e7fcf5af..1a1f79155 100644 --- a/src/gui/interface/DropDown.cpp +++ b/src/gui/interface/DropDown.cpp @@ -15,7 +15,7 @@ class DropDownWindow : public ui::Window public: DropDownWindow(DropDown * dropDown): - Window(dropDown->GetScreenPos() + ui::Point(-1, -1 - dropDown->optionIndex * 16), ui::Point(dropDown->Size.X+2, 1+dropDown->options.size()*16)), + Window(dropDown->GetScreenPos() + ui::Point(-1, -1 - dropDown->optionIndex * 16), ui::Point(dropDown->Size.X+2, 2+dropDown->options.size()*16)), dropDown(dropDown), appearance(dropDown->Appearance) { @@ -39,7 +39,7 @@ public: void OnDraw() override { Graphics * g = GetGraphics(); - g->clearrect(Position.X, Position.Y, Size.X, Size.Y); + g->DrawFilledRect(RectSized(Position, Size), 0x000000_rgb); } void setOption(String option) { diff --git a/src/gui/interface/SaveButton.cpp b/src/gui/interface/SaveButton.cpp index 088c2a1be..dca2bbc60 100644 --- a/src/gui/interface/SaveButton.cpp +++ b/src/gui/interface/SaveButton.cpp @@ -259,14 +259,14 @@ void SaveButton::Draw(const Point& screenPos) else 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 (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->XorDottedRect(RectSized(screenPos + (Size - thumbSize - Vec2{ 0, 21 }) / 2, thumbSize)); g->BlendText(screenPos + Vec2{ (Size.X-(Graphics::TextSize(name).X - 1))/2, Size.Y - 21 }, name, isMouseInside ? RGBA(255, 255, 255, 255) : RGBA(180, 180, 180, 255)); } if(isMouseInside && selectable) { - g->clearrect(screenPos.X+(Size.X-20), screenPos.Y+6, 14, 14); + g->DrawFilledRect(RectSized(screenPos + Vec2{ Size.X - 19, 7 }, Vec2{ 13, 13 }), 0x000000_rgb); g->drawrect(screenPos.X+(Size.X-20), screenPos.Y+6, 14, 14, 255, 255, 255, 255); if(selected) g->fillrect(screenPos.X+(Size.X-18), screenPos.Y+8, 10, 10, 255, 255, 255, 255); diff --git a/src/gui/login/LoginView.cpp b/src/gui/login/LoginView.cpp index be91522a8..e8ccc8f11 100644 --- a/src/gui/login/LoginView.cpp +++ b/src/gui/login/LoginView.cpp @@ -124,7 +124,7 @@ void LoginView::OnTick(float dt) void LoginView::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); } diff --git a/src/gui/options/OptionsView.cpp b/src/gui/options/OptionsView.cpp index 4aa4b27fe..aa1f9f3a4 100644 --- a/src/gui/options/OptionsView.cpp +++ b/src/gui/options/OptionsView.cpp @@ -158,7 +158,7 @@ OptionsView::OptionsView(): { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); } @@ -540,7 +540,7 @@ void OptionsView::AttachController(OptionsController * c_) void OptionsView::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); } diff --git a/src/gui/preview/PreviewView.cpp b/src/gui/preview/PreviewView.cpp index 6501b2a19..ebb5770c7 100644 --- a/src/gui/preview/PreviewView.cpp +++ b/src/gui/preview/PreviewView.cpp @@ -282,7 +282,7 @@ void PreviewView::OnDraw() Graphics * g = GetGraphics(); //Window Background+Outline - g->clearrect(Position.X-2, Position.Y-2, Size.X+4, Size.Y+4); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); //Save preview (top-left) if (savePreview) diff --git a/src/gui/profile/ProfileActivity.cpp b/src/gui/profile/ProfileActivity.cpp index 7591a87ad..046f0420d 100644 --- a/src/gui/profile/ProfileActivity.cpp +++ b/src/gui/profile/ProfileActivity.cpp @@ -232,7 +232,7 @@ void ProfileActivity::OnTick(float dt) void ProfileActivity::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); } diff --git a/src/gui/render/RenderView.cpp b/src/gui/render/RenderView.cpp index b81367307..f24871db4 100644 --- a/src/gui/render/RenderView.cpp +++ b/src/gui/render/RenderView.cpp @@ -155,7 +155,7 @@ void RenderView::NotifyColourChanged(RenderModel * sender) void RenderView::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(-1, -1, WINDOWW+1, WINDOWH+1); + g->DrawFilledRect(RectSized({ 0, 0 }, WINDOW), 0x000000_rgb); if(ren) { ren->clearScreen(); diff --git a/src/gui/tags/TagsView.cpp b/src/gui/tags/TagsView.cpp index ae26ec4b2..23e50897e 100644 --- a/src/gui/tags/TagsView.cpp +++ b/src/gui/tags/TagsView.cpp @@ -52,7 +52,7 @@ TagsView::TagsView(): void TagsView::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); } diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index ea4c1613c..4602d9694 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -3908,7 +3908,7 @@ int LuaScriptInterface::graphics_drawCircle(lua_State * l) if (a<0) a = 0; else if (a>255) a = 255; - luacon_g->drawcircle(x, y, abs(rx), abs(ry), r, g, b, a); + luacon_g->BlendEllipse({ x, y }, { abs(rx), abs(ry) }, RGBA(r, g, b, a)); return 0; } @@ -3932,7 +3932,7 @@ int LuaScriptInterface::graphics_fillCircle(lua_State * l) if (a<0) a = 0; else if (a>255) a = 255; - luacon_g->fillcircle(x, y, abs(rx), abs(ry), r, g, b, a); + luacon_g->BlendFilledEllipse({ x, y }, { abs(rx), abs(ry) }, RGBA(r, g, b, a)); return 0; } diff --git a/src/lua/LuaWindow.cpp b/src/lua/LuaWindow.cpp index ff8fa84fb..2b21d72c9 100644 --- a/src/lua/LuaWindow.cpp +++ b/src/lua/LuaWindow.cpp @@ -80,7 +80,7 @@ LuaWindow::LuaWindow(lua_State * l) : void OnDraw() override { Graphics * g = ui::Engine::Ref().g; - g->clearrect(Position.X-2, Position.Y-2, Size.X+4, Size.Y+4); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); luaWindow->triggerOnDraw(); } diff --git a/src/tasks/TaskWindow.cpp b/src/tasks/TaskWindow.cpp index 7f22e201b..4ea78900b 100644 --- a/src/tasks/TaskWindow.cpp +++ b/src/tasks/TaskWindow.cpp @@ -86,7 +86,7 @@ void TaskWindow::OnTick(float dt) void TaskWindow::OnDraw() { Graphics * g = GetGraphics(); - g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); g->draw_line(Position.X, Position.Y + Size.Y-17, Position.X + Size.X - 1, Position.Y + Size.Y-17, 255, 255, 255, 255);