Add hihglight tile id feature to Canvas
This commit is contained in:
@@ -463,6 +463,17 @@ void Canvas::DrawGrid(float grid_step) {
|
|||||||
ImVec2(canvas_p1_.x, canvas_p0_.y + y),
|
ImVec2(canvas_p1_.x, canvas_p0_.y + y),
|
||||||
IM_COL32(200, 200, 200, 50), 0.5f);
|
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_) {
|
if (enable_hex_tile_labels_) {
|
||||||
// Draw the hex ID of the tile in the center of the tile square
|
// Draw the hex ID of the tile in the center of the tile square
|
||||||
for (float x = fmodf(scrolling_.x, grid_step);
|
for (float x = fmodf(scrolling_.x, grid_step);
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ class Canvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto set_current_labels(int i) { current_labels_ = i; }
|
auto set_current_labels(int i) { current_labels_ = i; }
|
||||||
|
auto set_highlight_tile_id(int i) { highlight_tile_id = i; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool enable_grid_ = true;
|
bool enable_grid_ = true;
|
||||||
@@ -125,6 +126,7 @@ class Canvas {
|
|||||||
float global_scale_ = 1.0f;
|
float global_scale_ = 1.0f;
|
||||||
|
|
||||||
int current_labels_ = 0;
|
int current_labels_ = 0;
|
||||||
|
int highlight_tile_id = -1;
|
||||||
|
|
||||||
ImDrawList* draw_list_;
|
ImDrawList* draw_list_;
|
||||||
ImVector<ImVec2> points_;
|
ImVector<ImVec2> points_;
|
||||||
|
|||||||
Reference in New Issue
Block a user