Update DrawTileSelector to support variable tile height
- Modified DrawTileSelector function to accept an additional parameter for tile height, defaulting to the original size if not provided. - Adjusted the logic for calculating the second point in the tile selection to use the new height parameter, improving flexibility in tile rendering.
This commit is contained in:
@@ -394,11 +394,14 @@ void Canvas::DrawTileOnBitmap(int tile_size, gfx::Bitmap *bitmap,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Canvas::DrawTileSelector(int size) {
|
bool Canvas::DrawTileSelector(int size, int size_y) {
|
||||||
const ImGuiIO &io = GetIO();
|
const ImGuiIO &io = GetIO();
|
||||||
const bool is_hovered = IsItemHovered();
|
const bool is_hovered = IsItemHovered();
|
||||||
const ImVec2 origin(canvas_p0_.x + scrolling_.x, canvas_p0_.y + scrolling_.y);
|
const ImVec2 origin(canvas_p0_.x + scrolling_.x, canvas_p0_.y + scrolling_.y);
|
||||||
const ImVec2 mouse_pos(io.MousePos.x - origin.x, io.MousePos.y - origin.y);
|
const ImVec2 mouse_pos(io.MousePos.x - origin.x, io.MousePos.y - origin.y);
|
||||||
|
if (size_y == 0) {
|
||||||
|
size_y = size;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_hovered && IsMouseClicked(ImGuiMouseButton_Left)) {
|
if (is_hovered && IsMouseClicked(ImGuiMouseButton_Left)) {
|
||||||
if (!points_.empty()) {
|
if (!points_.empty()) {
|
||||||
@@ -409,7 +412,7 @@ bool Canvas::DrawTileSelector(int size) {
|
|||||||
painter_pos.y = std::floor((double)mouse_pos.y / size) * size;
|
painter_pos.y = std::floor((double)mouse_pos.y / size) * size;
|
||||||
|
|
||||||
points_.push_back(painter_pos);
|
points_.push_back(painter_pos);
|
||||||
points_.push_back(ImVec2(painter_pos.x + size, painter_pos.y + size));
|
points_.push_back(ImVec2(painter_pos.x + size, painter_pos.y + size_y));
|
||||||
mouse_pos_in_canvas_ = painter_pos;
|
mouse_pos_in_canvas_ = painter_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class Canvas : public SharedRom {
|
|||||||
|
|
||||||
// Dictates which tile is currently selected based on what the user clicks
|
// Dictates which tile is currently selected based on what the user clicks
|
||||||
// in the canvas window. Represented and split apart into a grid of tiles.
|
// in the canvas window. Represented and split apart into a grid of tiles.
|
||||||
bool DrawTileSelector(int size);
|
bool DrawTileSelector(int size, int size_y = 0);
|
||||||
|
|
||||||
// Draws the selection rectangle when the user is selecting multiple tiles
|
// Draws the selection rectangle when the user is selecting multiple tiles
|
||||||
void DrawSelectRect(int current_map, int tile_size = 0x10,
|
void DrawSelectRect(int current_map, int tile_size = 0x10,
|
||||||
|
|||||||
Reference in New Issue
Block a user