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
@@ -16,6 +16,7 @@
|
||||
#include "game/table.hpp"
|
||||
#include "ui/manager.hpp"
|
||||
#include "ui/setup.hpp"
|
||||
#include "ui/draw.hpp"
|
||||
|
||||
namespace bmh::ui {
|
||||
namespace {
|
||||
@@ -92,15 +93,11 @@ void copy_region(Image& out, const Image& source, int sx, int sy, int x, int y,
|
||||
sx + width > source.width || sy + height > source.height ||
|
||||
x + width > out.width || y + height > out.height)
|
||||
throw FormatError("league table: original atlas bounds");
|
||||
for (int dy = 0; dy < height; ++dy) for (int dx = 0; dx < width; ++dx) {
|
||||
const auto pixel = source.pixels[size_t(sy + dy) * size_t(source.width) + size_t(sx + dx)];
|
||||
if (pixel != transparent) out.at(x + dx, y + dy) = pixel;
|
||||
}
|
||||
draw::copy_unclipped(out, source, sx, sy, x, y, width, height, transparent);
|
||||
}
|
||||
|
||||
void fill_region(Image& out, int x, int y, int width, int height, uint8_t color) {
|
||||
for (int dy = y; dy < y + height; ++dy)
|
||||
for (int dx = x; dx < x + width; ++dx) out.at(dx, dy) = color;
|
||||
draw::fill(out, x, y, width, height, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user