added missing tools

This commit is contained in:
Geoffray Levasseur committed 2026-11-03 11:33:57 +01:00
1 parent 9afe83e68e
commit 534c172874
2 files changed
+45

No files matched your search

+7
View File
@@ -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 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); 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 btnFrame(Dpi::Canvas &canvas, const QRect &rect, const Texture &texture);
void editFrame(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). // 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); 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); 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 } // namespace Cevo
+38
View File
@@ -244,6 +244,18 @@ void frame(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, QColor cl0, QCol
canvas.lineTo(x0, y1); 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) void rframe(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, QColor cl0, QColor cl1)
{ {
canvas.pen().setColor(cl0); 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 } // namespace Cevo