multiple intricate implementations
This commit is contained in:
1 parent
7aa4ea4425
commit
77690cbd96
109 files changed
+2045
-56
No files matched your search
@@ -241,5 +241,14 @@ void vDarkGradient(Dpi::Canvas &canvas, int x, int y, int height, int kind);
|
||||
// ScreenTools.pas's NumberBar(): a labeled stat row (title + DLine divider
|
||||
// + right-aligned number), skipped entirely if val <= 0.
|
||||
void numberBar(Dpi::Canvas &canvas, int x, int y, const QString &cap, int val, const Texture &texture);
|
||||
// ScreenTools.pas's UnderlinedTitleValue(): a title on the left and a value
|
||||
// on the right of a bevelled divider line.
|
||||
void underlinedTitleValue(Dpi::Canvas &canvas, const QString &title, const QString &value, int x, int y, int width);
|
||||
// ScreenTools.pas's PaintLogo(): draws the C-evo logo tinted with the given
|
||||
// colours at x,y.
|
||||
void paintLogo(Dpi::Canvas &canvas, int x, int y, QColor lightColor, QColor shadeColor);
|
||||
// ScreenTools.pas's InitOrnament(): recolours the ornament sprite to the
|
||||
// current texture's bevel colours (once).
|
||||
void initOrnament();
|
||||
|
||||
} // namespace Cevo
|
||||
@@ -935,4 +935,54 @@ void numberBar(Dpi::Canvas &canvas, int x, int y, const QString &cap, int val, c
|
||||
risedTextOut(canvas, x + 170 - biColorTextWidth(canvas, s), y, s);
|
||||
}
|
||||
|
||||
void underlinedTitleValue(Dpi::Canvas &canvas, const QString &title, const QString &value, int x, int y, int width)
|
||||
{
|
||||
dLine(canvas, x, x + width, y + 19, MainTexture->colorBevelLight, MainTexture->colorBevelShade);
|
||||
risedTextOut(canvas, x, y, title);
|
||||
risedTextOut(canvas, x + width - biColorTextWidth(canvas, value), y, value);
|
||||
}
|
||||
|
||||
void paintLogo(Dpi::Canvas &canvas, int x, int y, QColor lightColor, QColor shadeColor)
|
||||
{
|
||||
GraphicSetItem *logo = Templates ? Templates->searchByName(QStringLiteral("Logo")) : nullptr;
|
||||
if (!logo)
|
||||
return;
|
||||
drawBufferEnsureSize(logo->width, logo->height);
|
||||
drawBuffer.canvas().begin();
|
||||
drawBuffer.canvas().copyRect(QRect(0, 0, logo->width, logo->height), canvas, QRect(x, y, logo->width, logo->height));
|
||||
drawBuffer.canvas().end();
|
||||
imageOpBCC(drawBuffer, Templates->data, 0, 0, logo->left, logo->top, logo->width, logo->height,
|
||||
colorToDelphi(lightColor), colorToDelphi(shadeColor));
|
||||
canvas.copyRect(QRect(x, y, logo->width, logo->height), drawBuffer.canvas(), QRect(0, 0, logo->width, logo->height));
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool ornamentInitialized = false;
|
||||
}
|
||||
|
||||
void initOrnament()
|
||||
{
|
||||
GraphicSetItem *ornament = HGrSystem2 ? HGrSystem2->searchByName(QStringLiteral("Ornament")) : nullptr;
|
||||
if (ornamentInitialized || !ornament || !MainTexture)
|
||||
return;
|
||||
const QColor light = MainTexture->colorBevelLight;
|
||||
const auto mix = [](int shade, int lightValue) { return ((shade & 0xFC) >> 2) * 3 + ((lightValue & 0xFC) >> 2); };
|
||||
const QColor shade(mix(MainTexture->colorBevelShade.red(), light.red()),
|
||||
mix(MainTexture->colorBevelShade.green(), light.green()),
|
||||
mix(MainTexture->colorBevelShade.blue(), light.blue()));
|
||||
QImage &image = HGrSystem2->data.image();
|
||||
const int left = Dpi::scaleToNative(ornament->left);
|
||||
const int top = Dpi::scaleToNative(ornament->top);
|
||||
for (int y = top; y < top + Dpi::scaleToNative(ornament->height) && y < image.height(); ++y) {
|
||||
for (int x = left; x < left + Dpi::scaleToNative(ornament->width) && x < image.width(); ++x) {
|
||||
const QRgb pixel = image.pixel(x, y) & 0xFFFFFFu;
|
||||
if (pixel == 0xFF0000u) // pure red marks the light part
|
||||
image.setPixelColor(x, y, light);
|
||||
else if (pixel == 0x0000FFu) // pure blue marks the shade part
|
||||
image.setPixelColor(x, y, shade);
|
||||
}
|
||||
}
|
||||
ornamentInitialized = true;
|
||||
}
|
||||
|
||||
} // namespace Cevo
|
||||
Reference in new issue
Block a user