aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-11-22 23:17:47 +0100
committerkdx <kikoodx@paranoici.org>2023-11-22 23:17:47 +0100
commit7e6c533236c333f191b502419e5970d4a3d722a8 (patch)
tree96f1be341b982422f188a33e7d485ef79e7a0993
parent8cdbecd94d7c6f087f011f6d9bd4affadaedb1e2 (diff)
downloadaancyk-7e6c533236c333f191b502419e5970d4a3d722a8.tar.gz
editor erase visual
-rw-r--r--src/editor.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/editor.c b/src/editor.c
index fa9b209..664da15 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -14,6 +14,15 @@ editor_redraw(Window *this, Root *root)
tileset_set_alpha(root->tileset, 191);
grid_draw(root->brush, root->tileset, this, dx, dy);
tileset_set_alpha(root->tileset, 255);
+ } else if (this->in_focus) {
+ const SDL_Rect rect = {
+ this->mouse_x * root->cfg->tile_width,
+ this->mouse_y * root->cfg->tile_height,
+ root->cfg->tile_width,
+ root->cfg->tile_height
+ };
+ window_set_draw_color(this, 255, 0, 0, 255);
+ window_draw_rect(this, &rect);
}
if (this->clicked) {
@@ -43,6 +52,7 @@ editor_event(Window *this, Root *root, SDL_Event *e)
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
_ev_mouse(this, root);
+ this->redraw = true;
break;
case SDL_WINDOWEVENT:
if (e->window.event == SDL_WINDOWEVENT_LEAVE)
@@ -113,6 +123,8 @@ _ev_mouse(Window *this, Root *root)
if (sx >= root->cell->width)
break;
const int tile = grid_get(root->brush, x, y);
+ if (tile == 0)
+ continue;
grid_set(root->cell, sx, sy, tile);
}
}