From 534c1728744e2eebbe276432f2e5965c8795fe40 Mon Sep 17 00:00:00 2001 From: Geoffray Levasseur Date: Tue, 3 Nov 2026 11:33:57 +0100 Subject: [PATCH] added missing tools --- widget/include/Cevo/CevoScreenTools.h | 7 +++++ widget/src/CevoScreenTools.cpp | 38 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/widget/include/Cevo/CevoScreenTools.h b/widget/include/Cevo/CevoScreenTools.h index 5c69d33..3bb060c 100644 --- a/widget/include/Cevo/CevoScreenTools.h +++ b/widget/include/Cevo/CevoScreenTools.h @@ -122,6 +122,9 @@ void sprite(Dpi::Canvas &canvas, int xDst, int yDst, const GraphicSetItem &item) void frame(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, QColor cl0, QColor cl1); void rframe(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, QColor cl0, QColor cl1); +// A "double line" bevel effect (one line in cl0, a second offset by one +// pixel in cl1), e.g. used to separate a label from its value. +void dLine(Dpi::Canvas &canvas, int x0, int x1, int y, QColor cl0, QColor cl1); void btnFrame(Dpi::Canvas &canvas, const QRect &rect, const Texture &texture); void editFrame(Dpi::Canvas &canvas, const QRect &rect, const Texture &texture); // Unimplemented in the original ScreenTools.pas too (body is commented out there). @@ -152,4 +155,8 @@ void imageOpCBC(Dpi::Bitmap &dst, Dpi::Bitmap &src, int xDst, int yDst, int xSrc int width, int height, int color0, int color2); void imageOpCCC(Dpi::Bitmap &bmp, int x, int y, int width, int height, int color0, int color1, int color2); +// ScreenTools.pas's TurnToYear(): maps a game turn to a calendar year +// (negative = BC), using the same variable-length-era table as the original. +int turnToYear(int turn); + } // namespace Cevo diff --git a/widget/src/CevoScreenTools.cpp b/widget/src/CevoScreenTools.cpp index eabe8c8..ae90512 100644 --- a/widget/src/CevoScreenTools.cpp +++ b/widget/src/CevoScreenTools.cpp @@ -244,6 +244,18 @@ void frame(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, QColor cl0, QCol canvas.lineTo(x0, y1); } +void dLine(Dpi::Canvas &canvas, int x0, int x1, int y, QColor cl0, QColor cl1) +{ + canvas.pen().setColor(cl0); + canvas.moveTo(x0, y); + canvas.lineTo(x1, y); + canvas.pen().setColor(cl1); + canvas.moveTo(x0 + 1, y + 1); + canvas.lineTo(x1 + 1, y + 1); + canvas.setPixel(x0, y + 1, cl0); + canvas.setPixel(x1, y, cl1); +} + void rframe(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, QColor cl0, QColor cl1) { canvas.pen().setColor(cl0); @@ -535,4 +547,30 @@ void imageOpCCC(Dpi::Bitmap &bmp, int x, int y, int width, int height, int color } } +int turnToYear(int turn) +{ + int result = -4000; + if (turn <= 0) + return result; + + auto consume = [&](int span, int yearsPerTurn) { + const int n = std::min(span, turn); + result += n * yearsPerTurn; + turn -= n; + }; + + consume(60, 50); // Year -4000..-1000, Turn 0..60 + if (turn == 0) return result; + consume(40, 25); // Year -1000..0, Turn 60..100 + if (turn == 0) return result; + consume(75, 20); // Year 0..1500, Turn 100..175 + if (turn == 0) return result; + consume(25, 10); // Year 1500..1750, Turn 175..200 + if (turn == 0) return result; + consume(50, 2); // Year 1750..1850, Turn 200..250 + if (turn == 0) return result; + result += turn; // Year 1850.., Turn 250.. + return result; +} + } // namespace Cevo