ui/draw.hpp: one place for the pixel loops of fill and copy
67 file-local helpers (fill/rect/copy/copy_region/... in 39 screens) now call draw::fill, draw::copy_clipped or draw::copy_unclipped. Only the loops moved: every screen keeps its own wrapper with its bounds check and error text, so the contracts are unchanged. Eight helpers with special behaviour stay as they are (bank, season promotion, toto, tax animation, ...). Verified: 9 headless careers and the scripted UI walk (German and English data, 38 screens, about 5,460 steps each) give the same fingerprints as before. ctest: 209 of 211; other_games_ui_tests and ui_preparation_tests fail the same way without this change. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
901f3dec1c
commit
fb3c2fe757
40 files changed
+171
-206
No files matched your search
@@ -8,6 +8,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "ui/manager.hpp"
|
||||
#include "ui/draw.hpp"
|
||||
|
||||
namespace bmh::ui {
|
||||
namespace {
|
||||
@@ -25,15 +26,11 @@ void copy(Image& out, const Image& src, int sx, int sy, int x, int y, int w, int
|
||||
if (sx < 0 || sy < 0 || x < 0 || y < 0 || w < 0 || h < 0 ||
|
||||
sx + w > src.width || sy + h > src.height || x + w > out.width || y + h > out.height)
|
||||
throw FormatError("top scorers: Original sprite bounds");
|
||||
for (int yy = 0; yy < h; ++yy)
|
||||
for (int xx = 0; xx < w; ++xx)
|
||||
out.at(x + xx, y + yy) = src.pixels[size_t(sy + yy) * size_t(src.width) + size_t(sx + xx)];
|
||||
draw::copy_unclipped(out, src, sx, sy, x, y, w, h, -1);
|
||||
}
|
||||
|
||||
void fill(Image& out, int x, int y, int w, int h, uint8_t color) {
|
||||
for (int yy = y; yy < y + h; ++yy)
|
||||
for (int xx = x; xx < x + w; ++xx)
|
||||
out.at(xx, yy) = color;
|
||||
draw::fill(out, x, y, w, h, color);
|
||||
}
|
||||
|
||||
std::string source_number(unsigned value, unsigned width = 0) {
|
||||
|
||||
Reference in new issue
Block a user