added missing tools
This commit is contained in:
1 parent
e71c06ee31
commit
f9f00c8622
2 files changed
+76
-2
No files matched your search
@@ -87,6 +87,15 @@ extern GraphicSet *HGrSystem;
|
|||||||
extern GraphicSet *HGrSystem2;
|
extern GraphicSet *HGrSystem2;
|
||||||
extern GraphicSet *Templates;
|
extern GraphicSet *Templates;
|
||||||
extern Dpi::Bitmap *Colors; // palette lookup bitmap, indexed by clkAge0/cli* below
|
extern Dpi::Bitmap *Colors; // palette lookup bitmap, indexed by clkAge0/cli* below
|
||||||
|
// ScreenTools.pas's `Paper` decorative background bitmap (Graphics/Paper.jpg)
|
||||||
|
// - null until the application's asset-loading step loads it (no central
|
||||||
|
// UnitInit exists yet, so the first consumer that needs it loads it lazily).
|
||||||
|
extern Dpi::Bitmap paper;
|
||||||
|
|
||||||
|
// ScreenTools.pas's magenta/half-magenta transparency color-key constants
|
||||||
|
// (also used by loadGraphicSet()'s own mask generation).
|
||||||
|
constexpr QRgb TransparentColor1 = 0xFF00FF;
|
||||||
|
constexpr QRgb TransparentColor2 = 0x7F007F;
|
||||||
// ScreenTools.pas's "icons.bmp" sprite sheet (improvements/wonders, big
|
// ScreenTools.pas's "icons.bmp" sprite sheet (improvements/wonders, big
|
||||||
// size) + its per-icon slot size; also populated by app asset-loading.
|
// size) + its per-icon slot size; also populated by app asset-loading.
|
||||||
extern Dpi::Bitmap *bigImp;
|
extern Dpi::Bitmap *bigImp;
|
||||||
@@ -145,6 +154,16 @@ void corner(Dpi::Canvas &canvas, int x, int y, int kind, const Texture &texture)
|
|||||||
|
|
||||||
void fill(Dpi::Canvas &canvas, int left, int top, int width, int height, int xOffset = 0, int yOffset = 0);
|
void fill(Dpi::Canvas &canvas, int left, int top, int width, int height, int xOffset = 0, int yOffset = 0);
|
||||||
void fill(Dpi::Canvas &canvas, const QRect &rect, const QPoint &offset = QPoint());
|
void fill(Dpi::Canvas &canvas, const QRect &rect, const QPoint &offset = QPoint());
|
||||||
|
// Seamlessly tiles `texture` (wrapping at its own width/height) into the
|
||||||
|
// given rectangle, offset by (xOffset,yOffset) - e.g. a background that
|
||||||
|
// must look continuous regardless of where the painted rect starts.
|
||||||
|
void fillSeamless(Dpi::Canvas &canvas, int left, int top, int width, int height, int xOffset, int yOffset,
|
||||||
|
Dpi::Bitmap &texture);
|
||||||
|
void fillRectSeamless(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, int xOffset, int yOffset,
|
||||||
|
Dpi::Bitmap &texture);
|
||||||
|
// Replaces every pixel in `dest` equal to transparentColor with the
|
||||||
|
// corresponding (wrapped) pixel of `texture`.
|
||||||
|
void texturize(Dpi::Bitmap &dest, Dpi::Bitmap &texture, QColor transparentColor);
|
||||||
void paintBackground(Dpi::Canvas &canvas, int left, int top, int width, int height,
|
void paintBackground(Dpi::Canvas &canvas, int left, int top, int width, int height,
|
||||||
int formWidth = 0, int formHeight = 0);
|
int formWidth = 0, int formHeight = 0);
|
||||||
// Draws a HGrSystem-sprited progress bar: `pos` pixels already filled,
|
// Draws a HGrSystem-sprited progress bar: `pos` pixels already filled,
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ GraphicSet *HGrSystem2 = nullptr;
|
|||||||
GraphicSet *Templates = nullptr;
|
GraphicSet *Templates = nullptr;
|
||||||
Dpi::Bitmap *Colors = nullptr;
|
Dpi::Bitmap *Colors = nullptr;
|
||||||
Dpi::Bitmap *bigImp = nullptr;
|
Dpi::Bitmap *bigImp = nullptr;
|
||||||
|
Dpi::Bitmap paper;
|
||||||
|
|
||||||
QColor colorFromDelphi(int value)
|
QColor colorFromDelphi(int value)
|
||||||
{
|
{
|
||||||
@@ -152,8 +153,6 @@ GraphicSet *loadGraphicSet(const QString &name, bool transparency)
|
|||||||
result->resetPixUsed();
|
result->resetPixUsed();
|
||||||
|
|
||||||
if (transparency) {
|
if (transparency) {
|
||||||
constexpr QRgb TransparentColor1 = 0xFF00FF;
|
|
||||||
constexpr QRgb TransparentColor2 = 0x7F007F;
|
|
||||||
result->mask.setSize(result->data.width(), result->data.height());
|
result->mask.setSize(result->data.width(), result->data.height());
|
||||||
Dpi::PixelPointer dataPixel(&result->data.image(), 0, 0);
|
Dpi::PixelPointer dataPixel(&result->data.image(), 0, 0);
|
||||||
Dpi::PixelPointer maskPixel(&result->mask.image(), 0, 0);
|
Dpi::PixelPointer maskPixel(&result->mask.image(), 0, 0);
|
||||||
@@ -341,6 +340,62 @@ void fill(Dpi::Canvas &canvas, const QRect &rect, const QPoint &offset)
|
|||||||
fill(canvas, rect.left(), rect.top(), rect.width(), rect.height(), offset.x(), offset.y());
|
fill(canvas, rect.left(), rect.top(), rect.width(), rect.height(), offset.x(), offset.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fillSeamless(Dpi::Canvas &canvas, int left, int top, int width, int height, int xOffset, int yOffset,
|
||||||
|
Dpi::Bitmap &texture)
|
||||||
|
{
|
||||||
|
if (texture.width() <= 0 || texture.height() <= 0)
|
||||||
|
return;
|
||||||
|
while (xOffset < 0)
|
||||||
|
xOffset += texture.width();
|
||||||
|
while (yOffset < 0)
|
||||||
|
yOffset += texture.height();
|
||||||
|
|
||||||
|
for (int y = (top + yOffset) / texture.height(); y <= (top + yOffset + height - 1) / texture.height(); ++y) {
|
||||||
|
int y0cut = top + yOffset - y * texture.height();
|
||||||
|
if (y0cut < 0)
|
||||||
|
y0cut = 0;
|
||||||
|
int y1cut = (y + 1) * texture.height() - (top + yOffset + height);
|
||||||
|
if (y1cut < 0)
|
||||||
|
y1cut = 0;
|
||||||
|
for (int x = (left + xOffset) / texture.width(); x <= (left + xOffset + width - 1) / texture.width(); ++x) {
|
||||||
|
int x0cut = left + xOffset - x * texture.width();
|
||||||
|
if (x0cut < 0)
|
||||||
|
x0cut = 0;
|
||||||
|
int x1cut = (x + 1) * texture.width() - (left + xOffset + width);
|
||||||
|
if (x1cut < 0)
|
||||||
|
x1cut = 0;
|
||||||
|
canvas.copyRect(QRect(x * texture.width() + x0cut - xOffset, y * texture.height() + y0cut - yOffset,
|
||||||
|
texture.width() - x0cut - x1cut, texture.height() - y0cut - y1cut),
|
||||||
|
texture.canvas(), QRect(x0cut, y0cut, texture.width() - x0cut - x1cut,
|
||||||
|
texture.height() - y0cut - y1cut));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void fillRectSeamless(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, int xOffset, int yOffset,
|
||||||
|
Dpi::Bitmap &texture)
|
||||||
|
{
|
||||||
|
fillSeamless(canvas, x0, y0, x1 - x0, y1 - y0, xOffset, yOffset, texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
void texturize(Dpi::Bitmap &dest, Dpi::Bitmap &texture, QColor transparentColor)
|
||||||
|
{
|
||||||
|
if (texture.width() <= 0 || texture.height() <= 0)
|
||||||
|
return;
|
||||||
|
const QRgb transparentRgb = transparentColor.rgb() & 0xFFFFFFu;
|
||||||
|
Dpi::PixelPointer dstPixel(&dest.image(), 0, 0);
|
||||||
|
for (int y = 0; y < dest.height(); ++y) {
|
||||||
|
for (int x = 0; x < dest.width(); ++x) {
|
||||||
|
if ((dstPixel.pixelRGB() & 0xFFFFFFu) == transparentRgb) {
|
||||||
|
Dpi::PixelPointer srcPixel(&texture.image(), x % texture.width(), y % texture.height());
|
||||||
|
dstPixel.setPixelRGB(srcPixel.pixelRGB());
|
||||||
|
}
|
||||||
|
dstPixel.nextPixel();
|
||||||
|
}
|
||||||
|
dstPixel.nextLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void paintBackground(Dpi::Canvas &canvas, int left, int top, int width, int height, int formWidth, int formHeight)
|
void paintBackground(Dpi::Canvas &canvas, int left, int top, int width, int height, int formWidth, int formHeight)
|
||||||
{
|
{
|
||||||
Q_UNUSED(formWidth);
|
Q_UNUSED(formWidth);
|
||||||
|
|||||||
Reference in new issue
Block a user