From: John Tsiombikas Date: Thu, 19 Aug 2021 18:01:27 +0000 (+0300) Subject: dungeon drawing X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrlugburz;a=commitdiff_plain;h=d2306fabd6ad4a568174fe0f17dec0b24c202eac dungeon drawing --- diff --git a/tools/dunger/src/lview.c b/tools/dunger/src/lview.c index 16af530..8e0ee27 100644 --- a/tools/dunger/src/lview.c +++ b/tools/dunger/src/lview.c @@ -46,10 +46,36 @@ void zoom_lview(float dz) cellsz = xsz > ysz ? ysz : xsz; } -void lview_mouse(int x, int y) +static int bnstate[8]; + +void lview_mbutton(int bn, int press, int x, int y) { float hsz = cellsz / 2.0f; sel = pos_to_cell(x + hsz - vpx, vph - y + hsz - vpy, 0, 0); + bnstate[bn] = press; + + if(press) { + if(!sel) return; + if(bn == 0) { + sel->type = CELL_WALK; + } else if(bn == 2) { + sel->type = CELL_SOLID; + } + } +} + +void lview_mouse(int x, int y) +{ + float hsz = cellsz / 2.0f; + if(!(sel = pos_to_cell(x + hsz - vpx, vph - y + hsz - vpy, 0, 0))) { + return; + } + + if(bnstate[0]) { + sel->type = CELL_WALK; + } else if(bnstate[2]) { + sel->type = CELL_SOLID; + } } #define LTHICK 0.5f diff --git a/tools/dunger/src/lview.h b/tools/dunger/src/lview.h index 0788b71..07d3c57 100644 --- a/tools/dunger/src/lview.h +++ b/tools/dunger/src/lview.h @@ -11,6 +11,7 @@ void lview_viewport(int x, int y, int xsz, int ysz); void pan_lview(float dx, float dy); void zoom_lview(float dz); +void lview_mbutton(int bn, int press, int x, int y); void lview_mouse(int x, int y); void draw_lview(void); diff --git a/tools/dunger/src/main.c b/tools/dunger/src/main.c index fbb24c4..83d7fd0 100644 --- a/tools/dunger/src/main.c +++ b/tools/dunger/src/main.c @@ -226,6 +226,8 @@ static void mouse(int bn, int st, int x, int y) if(press) view_zoom -= 0.1; } + lview_mbutton(bidx, press, x, y); + utk_mbutton_event(bidx, press, x / uiscale, y / uiscale); glutPostRedisplay(); }