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
+3
-6
@@ -12,6 +12,7 @@
|
||||
#include "formats/savestate.hpp"
|
||||
#include "game/state.hpp"
|
||||
#include "ui/manager.hpp"
|
||||
#include "ui/draw.hpp"
|
||||
|
||||
namespace bmh::ui {
|
||||
namespace {
|
||||
@@ -77,15 +78,11 @@ LineupState project(const StaticMemory& memory, const LeImage& exe, const std::v
|
||||
return out;
|
||||
}
|
||||
void rect(Image& out, int x, int y, int w, int h, uint8_t color) {
|
||||
for (int yy = std::max(0,y); yy < std::min(out.height,y+h); ++yy)
|
||||
for (int xx = std::max(0,x); xx < std::min(out.width,x+w); ++xx) out.at(xx,yy) = color;
|
||||
draw::fill(out, x, y, w, h, color);
|
||||
}
|
||||
void copy(Image& out, const Image& src, int sx, int sy, int x, int y, int w, int h, int transparent = -1) {
|
||||
if (sx < 0 || sy < 0 || sx+w > src.width || sy+h > src.height) throw FormatError("lineup: original atlas bounds " + std::to_string(sx) + "," + std::to_string(sy) + ":" + std::to_string(w) + "x" + std::to_string(h) + " in " + std::to_string(src.width) + "x" + std::to_string(src.height));
|
||||
for (int yy=0; yy<h; ++yy) for (int xx=0; xx<w; ++xx) {
|
||||
const auto c=src.pixels.at(size_t(sy+yy)*src.width+sx+xx);
|
||||
if (c != transparent && x+xx>=0 && x+xx<out.width && y+yy>=0 && y+yy<out.height) out.at(x+xx,y+yy)=c;
|
||||
}
|
||||
draw::copy_clipped(out, src, sx, sy, x, y, w, h, transparent);
|
||||
}
|
||||
std::string number(uint64_t value, int width = 2) {
|
||||
auto s=std::to_string(value);
|
||||
|
||||
Reference in new issue
Block a user