continue amb els ambits
This commit is contained in:
@@ -14,9 +14,7 @@
|
||||
static constexpr int BORDER_PAD = 3;
|
||||
|
||||
// Abre el picker con un tileset
|
||||
void TilePicker::open(const std::string& tileset_name, int current_tile,
|
||||
int bg_color, int source_color, int target_color,
|
||||
int tile_spacing_in, int tile_spacing_out) {
|
||||
void TilePicker::open(const std::string& tileset_name, int current_tile, int bg_color, int source_color, int target_color, int tile_spacing_in, int tile_spacing_out) {
|
||||
tileset_ = Resource::Cache::get()->getSurface(tileset_name);
|
||||
if (!tileset_) {
|
||||
open_ = false;
|
||||
@@ -70,16 +68,15 @@ void TilePicker::open(const std::string& tileset_name, int current_tile,
|
||||
SDL_FRect src = {
|
||||
.x = static_cast<float>(col * src_cell),
|
||||
.y = static_cast<float>(row * src_cell),
|
||||
.w = TS, .h = TS};
|
||||
.w = TS,
|
||||
.h = TS};
|
||||
|
||||
// Destino: posición en el frame con spacing de salida
|
||||
int dst_x = BORDER_PAD + col * out_cell;
|
||||
int dst_y = BORDER_PAD + row * out_cell;
|
||||
|
||||
if (source_color >= 0 && target_color >= 0) {
|
||||
tileset_->renderWithColorReplace(dst_x, dst_y,
|
||||
static_cast<Uint8>(source_color),
|
||||
static_cast<Uint8>(target_color), &src);
|
||||
tileset_->renderWithColorReplace(dst_x, dst_y, static_cast<Uint8>(source_color), static_cast<Uint8>(target_color), &src);
|
||||
} else {
|
||||
SDL_FRect dst = {.x = static_cast<float>(dst_x), .y = static_cast<float>(dst_y), .w = TS, .h = TS};
|
||||
tileset_->render(&src, &dst);
|
||||
@@ -97,8 +94,7 @@ void TilePicker::open(const std::string& tileset_name, int current_tile,
|
||||
|
||||
visible_height_ = PlayArea::HEIGHT;
|
||||
|
||||
frame_dst_ = {.x = static_cast<float>(offset_x_), .y = static_cast<float>(offset_y),
|
||||
.w = static_cast<float>(frame_w), .h = static_cast<float>(frame_h)};
|
||||
frame_dst_ = {.x = static_cast<float>(offset_x_), .y = static_cast<float>(offset_y), .w = static_cast<float>(frame_w), .h = static_cast<float>(frame_h)};
|
||||
|
||||
// Si el frame es más alto que el play area, necesitará scroll
|
||||
if (frame_h > visible_height_) {
|
||||
@@ -138,8 +134,7 @@ void TilePicker::render() {
|
||||
int max_scroll = frame_h - visible_height_;
|
||||
scroll_y_ = std::clamp(scroll_y_, 0, max_scroll);
|
||||
|
||||
SDL_FRect src = {.x = 0, .y = static_cast<float>(scroll_y_),
|
||||
.w = frame_dst_.w, .h = static_cast<float>(visible_height_)};
|
||||
SDL_FRect src = {.x = 0, .y = static_cast<float>(scroll_y_), .w = frame_dst_.w, .h = static_cast<float>(visible_height_)};
|
||||
SDL_FRect dst = {.x = frame_dst_.x, .y = 0, .w = frame_dst_.w, .h = static_cast<float>(visible_height_)};
|
||||
frame_surface_->render(&src, &dst);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user