From c30531e0329441ab58edadb7ca95e599618f0429 Mon Sep 17 00:00:00 2001 From: Geoffray Levasseur Date: Wed, 4 Nov 2026 16:13:13 +0100 Subject: [PATCH] added city mark --- widget/include/Cevo/CevoScreenTools.h | 2 ++ widget/src/CevoScreenTools.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/widget/include/Cevo/CevoScreenTools.h b/widget/include/Cevo/CevoScreenTools.h index 4c76932..3cb9484 100644 --- a/widget/include/Cevo/CevoScreenTools.h +++ b/widget/include/Cevo/CevoScreenTools.h @@ -254,6 +254,8 @@ void paintLogo(Dpi::Canvas &canvas, int x, int y, QColor lightColor, QColor shad // ScreenTools.pas's InitOrnament(): recolours the ornament sprite to the // current texture's bevel colours (once). void initOrnament(); +// ScreenTools.pas's InitCityMark(): tints the city mark sprite (System graphics) with the texture's mark colour. +void initCityMark(const Texture &texture); // ScreenTools.pas's DarkenImage(): subtracts `change` from every colour channel (clamped at 0). void darkenImage(Dpi::Bitmap &bitmap, int change); diff --git a/widget/src/CevoScreenTools.cpp b/widget/src/CevoScreenTools.cpp index 947ccf3..b41baf7 100644 --- a/widget/src/CevoScreenTools.cpp +++ b/widget/src/CevoScreenTools.cpp @@ -1007,6 +1007,32 @@ void paintLogo(Dpi::Canvas &canvas, int x, int y, QColor lightColor, QColor shad canvas.copyRect(QRect(x, y, logo->width, logo->height), drawBuffer.canvas(), QRect(0, 0, logo->width, logo->height)); } +void initCityMark(const Texture &texture) +{ + if (!HGrSystem) + return; + const GraphicSetItem *mark1 = HGrSystem->searchByName(QStringLiteral("CityMark1")); + const GraphicSetItem *mark2 = HGrSystem->searchByName(QStringLiteral("CityMark2")); + if (!mark1 || !mark2) + return; + QImage &data = HGrSystem->data.image(); + QImage &mask = HGrSystem->mask.image(); + const QColor color = texture.colorMark; + for (int x = 0; x < mark1->width; ++x) { + for (int y = 0; y < mark1->height; ++y) { + if ((mask.pixel(mark1->left + x, mark1->top + y) & 0xFFFFFFu) != 0) + continue; + const int intensity = qRed(data.pixel(mark1->left + x, mark1->top + y)); + data.setPixel(mark2->left + x, mark2->top + y, + qRgb(color.red() * intensity / 0xFF, color.green() * intensity / 0xFF, + color.blue() * intensity / 0xFF)); + } + } + // (the original copies mark1.Width rows here, which is square anyway) + bitBltBitmap(HGrSystem->mask, mark2->left, mark2->top, mark1->width, mark1->width, HGrSystem->mask, mark1->left, + mark1->top); +} + void darkenImage(Dpi::Bitmap &bitmap, int change) { QImage &image = bitmap.image();