added missing functions
This commit is contained in:
1 parent
e9b239092d
commit
1e9ad56b0c
2 files changed
+46
No files matched your search
@@ -104,6 +104,10 @@ void fill(Dpi::Canvas &canvas, int left, int top, int width, int height, int xOf
|
||||
void fill(Dpi::Canvas &canvas, const QRect &rect, const QPoint &offset = QPoint());
|
||||
void paintBackground(Dpi::Canvas &canvas, int left, int top, int width, int height,
|
||||
int formWidth = 0, int formHeight = 0);
|
||||
// Draws a HGrSystem-sprited progress bar: `pos` pixels already filled,
|
||||
// `growth` more pixels animating in (negative: shrinking), out of `max`.
|
||||
void paintProgressBar(Dpi::Canvas &canvas, int kind, int x, int y, int pos, int growth, int max,
|
||||
const Texture &texture);
|
||||
|
||||
void biColorTextOut(Dpi::Canvas &canvas, QColor mainColor, QColor backColor, int x, int y, const QString &text);
|
||||
int biColorTextWidth(Dpi::Canvas &canvas, const QString &text);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "Dpi/DpiPixelPointer.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace Cevo {
|
||||
|
||||
@@ -178,6 +179,47 @@ void paintBackground(Dpi::Canvas &canvas, int left, int top, int width, int heig
|
||||
fill(canvas, left, top, width, height, 0, 0);
|
||||
}
|
||||
|
||||
void paintProgressBar(Dpi::Canvas &canvas, int kind, int x, int y, int pos, int growth, int max,
|
||||
const Texture &texture)
|
||||
{
|
||||
if (pos > max)
|
||||
pos = max;
|
||||
if (growth < 0) {
|
||||
pos += growth;
|
||||
if (pos < 0) {
|
||||
growth -= pos;
|
||||
if (growth > max)
|
||||
growth = max;
|
||||
pos = 0;
|
||||
}
|
||||
} else if (pos + growth > max) {
|
||||
growth = max - pos;
|
||||
}
|
||||
frame(canvas, x - 1, y - 1, x + max, y + 7, Qt::black, Qt::black);
|
||||
rframe(canvas, x - 2, y - 2, x + max + 1, y + 8, texture.colorBevelShade, texture.colorBevelLight);
|
||||
if (!HGrSystem)
|
||||
return;
|
||||
Dpi::Canvas &src = HGrSystem->data.canvas();
|
||||
for (int i = 0; i < pos / 8; ++i)
|
||||
canvas.copyRect(QRect(x + i * 8, y, 8, 7), src, QRect(104, 9 + 8 * kind, 8, 7));
|
||||
canvas.copyRect(QRect(x + 8 * (pos / 8), y, pos - 8 * (pos / 8), 7), src, QRect(104, 9 + 8 * kind, pos - 8 * (pos / 8), 7));
|
||||
if (growth > 0) {
|
||||
for (int i = 0; i < growth / 8; ++i)
|
||||
canvas.copyRect(QRect(x + pos + i * 8, y, 8, 7), src, QRect(112, 9 + 8 * kind, 8, 7));
|
||||
canvas.copyRect(QRect(x + pos + 8 * (growth / 8), y, growth - 8 * (growth / 8), 7), src,
|
||||
QRect(112, 9 + 8 * kind, growth - 8 * (growth / 8), 7));
|
||||
} else if (growth < 0) {
|
||||
for (int i = 0; i < -growth / 8; ++i)
|
||||
canvas.copyRect(QRect(x + pos + i * 8, y, 8, 7), src, QRect(104, 1, 8, 7));
|
||||
canvas.copyRect(QRect(x + pos + 8 * (-growth / 8), y, -growth - 8 * (-growth / 8), 7), src,
|
||||
QRect(104, 1, -growth - 8 * (-growth / 8), 7));
|
||||
}
|
||||
canvas.brush().setStyle(Qt::SolidPattern);
|
||||
canvas.brush().setColor(Qt::black);
|
||||
canvas.fillRect(QRect(x + pos + std::abs(growth), y, max - pos - std::abs(growth), 7));
|
||||
canvas.brush().setStyle(Qt::NoBrush);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// %c=combat %f=food %l=luxury %m=manufacture %n=nation %o=output
|
||||
|
||||
Reference in new issue
Block a user