Add hihglight tile id feature to Canvas

This commit is contained in:
scawful
2024-01-18 20:06:10 -05:00
parent dc31eea6a2
commit 0c2d724373
2 changed files with 13 additions and 0 deletions

View File

@@ -463,6 +463,17 @@ void Canvas::DrawGrid(float grid_step) {
ImVec2(canvas_p1_.x, canvas_p0_.y + y),
IM_COL32(200, 200, 200, 50), 0.5f);
if (highlight_tile_id != -1) {
int tile_x = highlight_tile_id % 8;
int tile_y = highlight_tile_id / 8;
ImVec2 tile_pos(canvas_p0_.x + scrolling_.x + tile_x * grid_step,
canvas_p0_.y + scrolling_.y + tile_y * grid_step);
ImVec2 tile_pos_end(tile_pos.x + grid_step, tile_pos.y + grid_step);
draw_list_->AddRectFilled(tile_pos, tile_pos_end,
IM_COL32(255, 0, 255, 255));
}
if (enable_hex_tile_labels_) {
// Draw the hex ID of the tile in the center of the tile square
for (float x = fmodf(scrolling_.x, grid_step);

View File

@@ -112,6 +112,7 @@ class Canvas {
}
auto set_current_labels(int i) { current_labels_ = i; }
auto set_highlight_tile_id(int i) { highlight_tile_id = i; }
private:
bool enable_grid_ = true;
@@ -125,6 +126,7 @@ class Canvas {
float global_scale_ = 1.0f;
int current_labels_ = 0;
int highlight_tile_id = -1;
ImDrawList* draw_list_;
ImVector<ImVec2> points_;