diff --git a/src/lib/SDLutility/drawing.cpp b/src/lib/SDLutility/drawing.cpp index e035dcaa..78121fa8 100644 --- a/src/lib/SDLutility/drawing.cpp +++ b/src/lib/SDLutility/drawing.cpp @@ -29,7 +29,7 @@ void drawPoint (SDL_Surface& surface, const cPosition& position, const cRgbColor& color) { SDL_Rect rect = {Sint16 (position.x()), Sint16 (position.y()), 1, 1}; - SDL_FillRect (&surface, &rect, toMappedSdlRGBAColor (color, surface.format)); + SDL_FillRect (&surface, &rect, toSdlAlphaColor (color, surface)); } //------------------------------------------------------------------------------ @@ -80,7 +80,7 @@ void drawRectangle (SDL_Surface& surface, const cBox& rectangle, cons SDL_Rect line_h = {rectangle.getMinCorner().x(), rectangle.getMinCorner().y(), size.x(), thickness}; - const auto sdlColor = toMappedSdlRGBAColor (color, surface.format); + const auto sdlColor = toSdlAlphaColor (color, surface); SDL_FillRect (&surface, &line_h, sdlColor); line_h.y += size.y() - thickness; @@ -96,7 +96,7 @@ void drawSelectionCorner (SDL_Surface& surface, const cBox& rectangle { constexpr int selectionCornerLineThickness = 3; const cPosition size = rectangle.getMaxCorner() - rectangle.getMinCorner(); - const auto sdlColor = toMappedSdlRGBAColor (color, surface.format); + const auto sdlColor = toSdlAlphaColor (color, surface); // cornersize is CellW or CellW*2(largeUnit)/4, or 16 for 32p (largest) cells. const int t = selectionCornerLineThickness; @@ -210,8 +210,8 @@ void putPixel (SDL_Surface& surface, const cPosition& position, Uint32 pixel) //------------------------------------------------------------------------------ void replaceColor (SDL_Surface& surface, const cRgbColor& sourceColor, const cRgbColor& destinationColor) { - const auto srcMapped = toMappedSdlRGBAColor (sourceColor, surface.format); - const auto destMapped = toMappedSdlRGBAColor (destinationColor, surface.format); + const auto srcMapped = toSdlAlphaColor (sourceColor, surface); + const auto destMapped = toSdlAlphaColor (destinationColor, surface); Uint32 key; const auto hadKey = SDL_GetColorKey (&surface, &key) == 0; diff --git a/src/lib/SDLutility/tosdl.cpp b/src/lib/SDLutility/tosdl.cpp index e109c0ca..c76bb793 100644 --- a/src/lib/SDLutility/tosdl.cpp +++ b/src/lib/SDLutility/tosdl.cpp @@ -32,13 +32,24 @@ SDL_Rect toSdlRect (const cBox& box) } //------------------------------------------------------------------------------ -Uint32 toMappedSdlRGBColor (const cRgbColor& color, const SDL_PixelFormat* format) +Uint32 toSdlColor (const cRgbColor& color, const SDL_PixelFormat* format) { return SDL_MapRGB (format, color.r, color.g, color.b); } //------------------------------------------------------------------------------ -Uint32 toMappedSdlRGBAColor (const cRgbColor& color, const SDL_PixelFormat* format) +Uint32 toSdlColor (const cRgbColor& color, const SDL_Surface& surface) +{ + return toSdlColor (color, surface.format); +} + +//------------------------------------------------------------------------------ +Uint32 toSdlAlphaColor (const cRgbColor& color, const SDL_PixelFormat* format) { return SDL_MapRGBA (format, color.r, color.g, color.b, color.a); } +//------------------------------------------------------------------------------ +Uint32 toSdlAlphaColor (const cRgbColor& color, const SDL_Surface& surface) +{ + return toSdlAlphaColor (color, surface.format); +} diff --git a/src/lib/SDLutility/tosdl.h b/src/lib/SDLutility/tosdl.h index 4358102a..19ef475c 100644 --- a/src/lib/SDLutility/tosdl.h +++ b/src/lib/SDLutility/tosdl.h @@ -29,7 +29,9 @@ class cBox; SDL_Rect toSdlRect (const cBox&); -Uint32 toMappedSdlRGBColor (const cRgbColor&, const SDL_PixelFormat*); -Uint32 toMappedSdlRGBAColor (const cRgbColor&, const SDL_PixelFormat*); +Uint32 toSdlColor (const cRgbColor&, const SDL_PixelFormat*); +Uint32 toSdlColor (const cRgbColor&, const SDL_Surface&); +Uint32 toSdlAlphaColor (const cRgbColor&, const SDL_PixelFormat*); +Uint32 toSdlAlphaColor (const cRgbColor&, const SDL_Surface&); #endif diff --git a/src/lib/output/video/unifonts.cpp b/src/lib/output/video/unifonts.cpp index 31415cad..8f208304 100644 --- a/src/lib/output/video/unifonts.cpp +++ b/src/lib/output/video/unifonts.cpp @@ -391,6 +391,7 @@ void cUnicodeFont::loadChars (eUnicodeFontCharset charset, eUnicodeFontType font int currentChar = 0; int pX = 0; int pY = 0; + const auto limitColor = SDL_MapRGB (surface->format, 0xFF, 0, 0xFF); for (int rows = 0; rows < highcount; rows++) { @@ -412,7 +413,7 @@ void cUnicodeFont::loadChars (eUnicodeFontCharset charset, eUnicodeFontType font pX = (cellW * cols) + pCol; pY = (cellH * rows) + pRow; - if (getPixel (*surface, cPosition (pX, pY)) != SDL_MapRGB (surface->format, 0xFF, 0, 0xFF)) + if (getPixel (*surface, cPosition (pX, pY)) != limitColor) { // offset Rect.x = pX; @@ -429,7 +430,7 @@ void cUnicodeFont::loadChars (eUnicodeFontCharset charset, eUnicodeFontType font pX = (cellW * cols) + pCol_w; pY = (cellH * rows) + pRow_w; - if (getPixel (*surface, cPosition (pX, pY)) != SDL_MapRGB (surface->format, 0xFF, 0, 0xFF)) + if (getPixel (*surface, cPosition (pX, pY)) != limitColor) { Rect.w = (pX - Rect.x) + 1; pCol_w = -1; // break loop diff --git a/src/lib/output/video/video.cpp b/src/lib/output/video/video.cpp index a002db41..71c7373d 100644 --- a/src/lib/output/video/video.cpp +++ b/src/lib/output/video/video.cpp @@ -26,6 +26,7 @@ #include "utility/log.h" #include "utility/mathtools.h" #include "utility/os.h" +#include "SDLutility/tosdl.h" #include "utility/thread/ismainthread.h" #include @@ -260,7 +261,7 @@ void cVideo::applyWindowMode() void cVideo::clearBuffer() { - SDL_FillRect (buffer, nullptr, SDL_MapRGB (buffer->format, 0, 0, 0)); + SDL_FillRect (buffer, nullptr, toSdlColor (cRgbColor::black(), *buffer)); } void cVideo::detectResolutions() diff --git a/src/lib/resources/loaddata.cpp b/src/lib/resources/loaddata.cpp index fcc16312..033f3bdd 100644 --- a/src/lib/resources/loaddata.cpp +++ b/src/lib/resources/loaddata.cpp @@ -40,6 +40,7 @@ #include "resources/uidata.h" #include "resources/vehicleuidata.h" #include "settings.h" +#include "SDLutility/tosdl.h" #include "utility/language.h" #include "utility/listhelpers.h" #include "utility/log.h" @@ -169,7 +170,7 @@ static void createShadowGfx() { // TODO: reduce size once we use texture. GraphicsData.gfx_shadow = AutoSurface (SDL_CreateRGBSurface (0, Video.getResolutionX(), Video.getResolutionY(), Video.getColDepth(), 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)); - SDL_FillRect (GraphicsData.gfx_shadow.get(), nullptr, SDL_MapRGBA (GraphicsData.gfx_shadow->format, 0, 0, 0, 50)); + SDL_FillRect (GraphicsData.gfx_shadow.get(), nullptr, toSdlAlphaColor (cRgbColor::black(50), *GraphicsData.gfx_shadow)); } /** diff --git a/src/lib/resources/playercolor.cpp b/src/lib/resources/playercolor.cpp index 317d6623..626db81b 100644 --- a/src/lib/resources/playercolor.cpp +++ b/src/lib/resources/playercolor.cpp @@ -63,7 +63,7 @@ namespace { auto texture = AutoSurface (SDL_CreateRGBSurface (0, 128, 128, 32, 0, 0, 0, 0)); - SDL_FillRect (texture.get(), nullptr, toMappedSdlRGBAColor (color, texture->format)); + SDL_FillRect (texture.get(), nullptr, toSdlAlphaColor (color, *texture)); auto hsvColor = color.toHsv(); @@ -122,7 +122,7 @@ namespace } SDL_Rect dest = {xPos, yPos, width, height}; - SDL_FillRect (texture.get(), &dest, toMappedSdlRGBAColor (getRandom (randomColors), texture->format)); + SDL_FillRect (texture.get(), &dest, toSdlAlphaColor (getRandom (randomColors), *texture)); } return texture; } diff --git a/src/ui/graphical/game/temp/drawingcache.cpp b/src/ui/graphical/game/temp/drawingcache.cpp index 1e56973b..23867bda 100644 --- a/src/ui/graphical/game/temp/drawingcache.cpp +++ b/src/ui/graphical/game/temp/drawingcache.cpp @@ -29,6 +29,7 @@ #include "resources/uidata.h" #include "resources/vehicleuidata.h" #include "settings.h" +#include "SDLutility/tosdl.h" #include "ui/graphical/game/animations/animationtimer.h" #include "ui/widgets/framecounter.h" #include "utility/mathtools.h" @@ -91,7 +92,7 @@ void sDrawingCacheEntry::init (const cVehicle& vehicle, const cMapView& map, con } surface = AutoSurface (SDL_CreateRGBSurface (0, width, height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)); - SDL_FillRect (surface.get(), nullptr, SDL_MapRGBA (surface->format, 0, 0, 0, 0)); + SDL_FillRect (surface.get(), nullptr, toSdlAlphaColor (cRgbColor::transparent(), *surface)); } void sDrawingCacheEntry::init (const cBuilding& building, double zoom_, unsigned long long frameNr) @@ -120,7 +121,7 @@ void sDrawingCacheEntry::init (const cBuilding& building, double zoom_, unsigned surface = AutoSurface (SDL_CreateRGBSurface (0, width, height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)); - SDL_FillRect (surface.get(), nullptr, SDL_MapRGBA (surface->format, 0, 0, 0, 0)); + SDL_FillRect (surface.get(), nullptr, toSdlAlphaColor(cRgbColor::transparent(), *surface)); } cDrawingCache::cDrawingCache (std::shared_ptr frameCounter_) : diff --git a/src/ui/graphical/game/widgets/chatbox.h b/src/ui/graphical/game/widgets/chatbox.h index 9cf27401..7cb5933d 100644 --- a/src/ui/graphical/game/widgets/chatbox.h +++ b/src/ui/graphical/game/widgets/chatbox.h @@ -228,17 +228,20 @@ void cChatBox::createBackground() nonFocusBackground = AutoSurface (SDL_CreateRGBSurface (0, size.x(), size.y(), Video.getColDepth(), 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)); focusBackground = AutoSurface (SDL_CreateRGBSurface (0, size.x(), size.y(), Video.getColDepth(), 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)); + const auto black_50 = toSdlAlphaColor (cRgbColor::black (50), *nonFocusBackground); + const auto black_100 = toSdlAlphaColor (cRgbColor::black (100), *focusBackground); + SDL_Rect chatListBackgroundRect = {chatList->getPosition().x() - getPosition().x(), chatList->getPosition().y() - getPosition().y(), chatList->getSize().x(), chatList->getSize().y()}; - SDL_FillRect (nonFocusBackground.get(), &chatListBackgroundRect, SDL_MapRGBA (nonFocusBackground->format, 0, 0, 0, 50)); - SDL_FillRect (focusBackground.get(), &chatListBackgroundRect, SDL_MapRGBA (focusBackground->format, 0, 0, 0, 100)); + SDL_FillRect (nonFocusBackground.get(), &chatListBackgroundRect, black_50); + SDL_FillRect (focusBackground.get(), &chatListBackgroundRect, black_100); SDL_Rect chatLineEditBackgroundRect = {chatLineEdit->getPosition().x() - getPosition().x() - 2, chatLineEdit->getPosition().y() - getPosition().y() - 2, chatLineEdit->getSize().x() + 4, chatLineEdit->getSize().y() + 4}; - SDL_FillRect (nonFocusBackground.get(), &chatLineEditBackgroundRect, SDL_MapRGBA (nonFocusBackground->format, 0, 0, 0, 50)); - SDL_FillRect (focusBackground.get(), &chatLineEditBackgroundRect, SDL_MapRGBA (focusBackground->format, 0, 0, 0, 100)); + SDL_FillRect (nonFocusBackground.get(), &chatLineEditBackgroundRect, black_50); + SDL_FillRect (focusBackground.get(), &chatLineEditBackgroundRect, black_100); SDL_Rect playerListBackgroundRect = {playersList->getPosition().x() - getPosition().x(), playersList->getPosition().y() - getPosition().y(), playersList->getSize().x(), playersList->getSize().y()}; - SDL_FillRect (nonFocusBackground.get(), &playerListBackgroundRect, SDL_MapRGBA (nonFocusBackground->format, 0, 0, 0, 50)); - SDL_FillRect (focusBackground.get(), &playerListBackgroundRect, SDL_MapRGBA (focusBackground->format, 0, 0, 0, 100)); + SDL_FillRect (nonFocusBackground.get(), &playerListBackgroundRect, black_50); + SDL_FillRect (focusBackground.get(), &playerListBackgroundRect, black_100); } #endif // ui_graphical_game_widgets_chatboxH diff --git a/src/ui/graphical/game/widgets/chatboxplayerlistviewitem.cpp b/src/ui/graphical/game/widgets/chatboxplayerlistviewitem.cpp index 4f5ba418..32727a1c 100644 --- a/src/ui/graphical/game/widgets/chatboxplayerlistviewitem.cpp +++ b/src/ui/graphical/game/widgets/chatboxplayerlistviewitem.cpp @@ -82,7 +82,7 @@ void cChatBoxPlayerListViewItem::updatePlayerFinishedTurn() SDL_Rect src = {player->getHasFinishedTurn() ? 10 : 0, 0, 10, 10}; AutoSurface readySurface (SDL_CreateRGBSurface (0, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0)); - SDL_SetColorKey (readySurface.get(), SDL_TRUE, toMappedSdlRGBAColor (cRgbColor (0, 1, 0), readySurface->format)); + SDL_SetColorKey (readySurface.get(), SDL_TRUE, toSdlAlphaColor (cRgbColor (0, 1, 0), *readySurface)); SDL_BlitSurface (GraphicsData.gfx_player_ready.get(), &src, readySurface.get(), nullptr); readyImage->setImage (readySurface.get()); diff --git a/src/ui/graphical/game/widgets/gamemessagelistviewitem.cpp b/src/ui/graphical/game/widgets/gamemessagelistviewitem.cpp index 1bedf9d1..2d9d329d 100644 --- a/src/ui/graphical/game/widgets/gamemessagelistviewitem.cpp +++ b/src/ui/graphical/game/widgets/gamemessagelistviewitem.cpp @@ -90,13 +90,13 @@ void cGameMessageListViewItem::createBackground() { default: case eGameMessageListViewItemBackgroundColor::DarkGray: - SDL_FillRect (background.get(), nullptr, SDL_MapRGBA (background->format, 0, 0, 0, alpha)); + SDL_FillRect (background.get(), nullptr, toSdlAlphaColor(cRgbColor::black(alpha), *background)); break; case eGameMessageListViewItemBackgroundColor::LightGray: - SDL_FillRect (background.get(), nullptr, SDL_MapRGBA (background->format, 0xFF, 0xFF, 0xFF, alpha)); + SDL_FillRect (background.get(), nullptr, toSdlAlphaColor (cRgbColor::white(alpha), *background)); break; case eGameMessageListViewItemBackgroundColor::Red: - SDL_FillRect (background.get(), nullptr, SDL_MapRGBA (background->format, 0xFF, 0, 0, alpha)); + SDL_FillRect (background.get(), nullptr, toSdlAlphaColor (cRgbColor::red(alpha), *background)); break; } } diff --git a/src/ui/graphical/game/widgets/minimapwidget.cpp b/src/ui/graphical/game/widgets/minimapwidget.cpp index 5607dae4..5529fb07 100644 --- a/src/ui/graphical/game/widgets/minimapwidget.cpp +++ b/src/ui/graphical/game/widgets/minimapwidget.cpp @@ -323,7 +323,7 @@ void cMiniMapWidget::drawUnits() if (!attackUnitsOnly || building->getStaticUnitData().canAttack) { const auto color = building->getOwner() ? building->getOwner()->getColor() : neutralColor; - SDL_FillRect (surface.get(), &rect, toMappedSdlRGBAColor (color, surface->format)); + SDL_FillRect (surface.get(), &rect, toSdlAlphaColor (color, *surface)); } } @@ -333,7 +333,7 @@ void cMiniMapWidget::drawUnits() if (!attackUnitsOnly || vehicle->getStaticUnitData().canAttack) { const auto color = vehicle->getOwner() ? vehicle->getOwner()->getColor() : neutralColor; - SDL_FillRect (surface.get(), &rect, toMappedSdlRGBAColor (color, surface->format)); + SDL_FillRect (surface.get(), &rect, toSdlAlphaColor (color, *surface)); } } @@ -343,7 +343,7 @@ void cMiniMapWidget::drawUnits() if (!attackUnitsOnly || vehicle->getStaticUnitData().canAttack) { const auto color = vehicle->getOwner() ? vehicle->getOwner()->getColor() : neutralColor; - SDL_FillRect (surface.get(), &rect, toMappedSdlRGBAColor (color, surface->format)); + SDL_FillRect (surface.get(), &rect, toSdlAlphaColor (color, *surface)); } } } diff --git a/src/ui/graphical/menu/dialogs/dialogcolorpicker.cpp b/src/ui/graphical/menu/dialogs/dialogcolorpicker.cpp index 23f1b5b4..dda645ba 100644 --- a/src/ui/graphical/menu/dialogs/dialogcolorpicker.cpp +++ b/src/ui/graphical/menu/dialogs/dialogcolorpicker.cpp @@ -144,7 +144,7 @@ AutoSurface cDialogColorPicker::createSelectedColorSurface() { AutoSurface surface (SDL_CreateRGBSurface (0, 50, 50, 32, 0, 0, 0, 0)); - SDL_FillRect (surface.get(), nullptr, toMappedSdlRGBAColor (colorPicker->getSelectedColor(), surface->format)); + SDL_FillRect (surface.get(), nullptr, toSdlAlphaColor (colorPicker->getSelectedColor(), *surface)); return surface; } diff --git a/src/ui/graphical/menu/widgets/colorpicker.cpp b/src/ui/graphical/menu/widgets/colorpicker.cpp index 182b7a27..add399a1 100644 --- a/src/ui/graphical/menu/widgets/colorpicker.cpp +++ b/src/ui/graphical/menu/widgets/colorpicker.cpp @@ -97,7 +97,7 @@ AutoSurface cRgbColorPicker::createColorsSurface() color.s = x * 100 / (size.x() - 1); color.v = 100 - (y * 100 / (size.y() - 1)); - putPixel (*surface, cPosition (x, y), toMappedSdlRGBAColor (color.toRgb(), surface->format)); + putPixel (*surface, cPosition (x, y), toSdlAlphaColor (color.toRgb(), surface->format)); } } @@ -118,7 +118,7 @@ AutoSurface cRgbColorPicker::createColorBarSurface() { const cPosition position (x, y); - putPixel (*surface, position, toMappedSdlRGBAColor (color.toRgb(), surface->format)); + putPixel (*surface, position, toSdlAlphaColor (color.toRgb(), surface->format)); } } @@ -130,7 +130,7 @@ AutoSurface cRgbColorPicker::createColorMarkerSurface() { AutoSurface surface (SDL_CreateRGBSurface (0, 3, 3, 32, 0, 0, 0, 0)); - SDL_FillRect (surface.get(), nullptr, toMappedSdlRGBColor (cRgbColor::white(), surface->format)); + SDL_FillRect (surface.get(), nullptr, toSdlColor (cRgbColor::white(), *surface)); drawPoint (*surface, cPosition (1, 1), cRgbColor (0xFF, 0, 0xFF)); return surface; @@ -141,7 +141,7 @@ AutoSurface cRgbColorPicker::createColorHueMarkerSurface() { AutoSurface surface (SDL_CreateRGBSurface (0, 15 + 2, 3, 32, 0, 0, 0, 0)); - SDL_FillRect (surface.get(), nullptr, toMappedSdlRGBColor (cRgbColor::white(), surface->format)); + SDL_FillRect (surface.get(), nullptr, toSdlColor (cRgbColor::white(), *surface)); drawLine (*surface, cPosition (1, 1), cPosition (16, 1), cRgbColor (0xFF, 0, 0xFF)); diff --git a/src/ui/graphical/menu/widgets/slider.cpp b/src/ui/graphical/menu/widgets/slider.cpp index 6e6993d7..fae472ae 100644 --- a/src/ui/graphical/menu/widgets/slider.cpp +++ b/src/ui/graphical/menu/widgets/slider.cpp @@ -202,7 +202,7 @@ void cSlider::createSurface (eSliderType sliderType) auto size = getSize(); surface = AutoSurface (SDL_CreateRGBSurface (0, size.x(), size.y(), Video.getColDepth(), 0, 0, 0, 0)); - SDL_FillRect (surface.get(), nullptr, toMappedSdlRGBAColor (cRgbColor::black(), surface->format)); + SDL_FillRect (surface.get(), nullptr, toSdlAlphaColor (cRgbColor::black(), *surface)); drawLine (*surface, cPosition (0, 0), cPosition (0, size.y()), cRgbColor (140, 102, 61)); drawLine (*surface, cPosition (size.x() - 1, 0), cPosition (size.x() - 1, size.y()), cRgbColor (140, 102, 61)); diff --git a/src/ui/graphical/menu/widgets/special/chatboxlandingplayerlistviewitem.cpp b/src/ui/graphical/menu/widgets/special/chatboxlandingplayerlistviewitem.cpp index 9bbc5123..ad3ba4ef 100644 --- a/src/ui/graphical/menu/widgets/special/chatboxlandingplayerlistviewitem.cpp +++ b/src/ui/graphical/menu/widgets/special/chatboxlandingplayerlistviewitem.cpp @@ -149,7 +149,7 @@ void cChatBoxLandingPlayerListViewItem::updatePlayerHasSelectedPosition() SDL_Rect src = {playerLandingStatus.hasSelectedPosition() ? 10 : 0, 0, 10, 10}; AutoSurface readySurface (SDL_CreateRGBSurface (0, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0)); - SDL_SetColorKey (readySurface.get(), SDL_TRUE, toMappedSdlRGBAColor (cRgbColor (0, 1, 0), readySurface->format)); + SDL_SetColorKey (readySurface.get(), SDL_TRUE, toSdlAlphaColor (cRgbColor (0, 1, 0), *readySurface)); SDL_BlitSurface (GraphicsData.gfx_player_ready.get(), &src, readySurface.get(), nullptr); readyImage->setImage (readySurface.get()); diff --git a/src/ui/graphical/menu/windows/windowreports/windowreports.cpp b/src/ui/graphical/menu/windows/windowreports/windowreports.cpp index 5ff0e9a1..63a4d32a 100644 --- a/src/ui/graphical/menu/windows/windowreports/windowreports.cpp +++ b/src/ui/graphical/menu/windows/windowreports/windowreports.cpp @@ -165,7 +165,7 @@ cWindowReports::cWindowReports (const cModel& model, std::string playerText = player->getName() + lngPack.i18n ("Punctuation~Colon") + lngPack.plural ("Comp~Point(s)", player->getScore (turnClock->getTurn())) + ", " + lngPack.plural ("Comp~EcoSphere(s)", player->getNumEcoSpheres()); AutoSurface colorSurface (SDL_CreateRGBSurface (0, 8, 8, Video.getColDepth(), 0, 0, 0, 0)); - SDL_FillRect (colorSurface.get(), nullptr, toMappedSdlRGBAColor (player->getColor(), colorSurface->format)); + SDL_FillRect (colorSurface.get(), nullptr, toSdlAlphaColor (player->getColor(), *colorSurface)); scoreFrame->emplaceChild (scoreFrame->getPosition() + cPosition (5, 20 + font->getFontHeight() * i), colorSurface.get()); ecosphereLabels.emplace_back (scoreFrame->emplaceChild (cBox (scoreFrame->getPosition() + cPosition (16, 20 + font->getFontHeight() * i), scoreFrame->getPosition() + cPosition (16 + 435, 20 + font->getFontHeight() * (i + 1))), playerText)); diff --git a/src/ui/widgets/window.cpp b/src/ui/widgets/window.cpp index e8fdcf00..430e7d19 100644 --- a/src/ui/widgets/window.cpp +++ b/src/ui/widgets/window.cpp @@ -49,7 +49,7 @@ void cWindow::draw (SDL_Surface& destination, const cBox& clipRect) switch (backgroundType) { case eWindowBackgrounds::Black: - SDL_FillRect (cVideo::buffer, nullptr, 0xFF000000); + SDL_FillRect (cVideo::buffer, nullptr, toSdlColor (cRgbColor::black(), *cVideo::buffer)); break; case eWindowBackgrounds::Alpha: // NOTE: this is not fully robust yet! It will not work if an