diff --git a/buttons.dat b/buttons.dat index d87b7e1..224b3d5 100644 --- a/buttons.dat +++ b/buttons.dat @@ -69,7 +69,7 @@ line 60 74 95 74 190 190 190 line 60 86 95 86 190 190 190 line 60 99 95 99 190 190 190 end -button grid 120 120 +button grid 120 180 line 10 35 100 35 190 190 190 line 10 75 100 75 190 190 190 line 35 10 35 100 190 190 190 diff --git a/example.map b/example.map index efdca61..bb06eaf 100644 Binary files a/example.map and b/example.map differ diff --git a/netmapr.c b/netmapr.c index aaea050..a49bc01 100644 --- a/netmapr.c +++ b/netmapr.c @@ -3064,6 +3064,7 @@ void drawmap(void) { Uint32 fillcol; int txoff,tyoff; int anchoreditem; + int x,y; if ((state == S_SAVING) || (state == S_LOADING) || (state == S_MAPNAMING)) { @@ -3095,31 +3096,19 @@ void drawmap(void) { fillcol = SDL_MapRGB(buffer->format, map[curmap].bgcol.r,map[curmap].bgcol.g,map[curmap].bgcol.b); SDL_FillRect(buffer, NULL, fillcol); - /* draw grid if required */ - if (grid) { - int x,y; - /* draw lines */ - for (x = 0; x < map[curmap].width; x += (gridsize*2)) { - drawline(buffer,x,0,x,map[curmap].height-1, gridcol, (LS_BIGDASH << 8) | 1); - if ((x+gridsize) < map[curmap].width) { - drawline(buffer,x+gridsize,0,x+gridsize,map[curmap].height-1, gridcol, (LS_DOTTED << 8) | 1); - } + /* always draw grid */ + for (x = 0; x < map[curmap].width; x += (gridsize*2)) { + drawline(buffer,x,0,x,map[curmap].height-1, gridcol, (LS_BIGDASH << 8) | 1); + if ((x+gridsize) < map[curmap].width) { + drawline(buffer,x+gridsize,0,x+gridsize,map[curmap].height-1, gridcol, (LS_DOTTED << 8) | 1); } + } - for (y = 0; y < map[curmap].height; y += (gridsize*2)) { - drawline(buffer,0,y,map[curmap].width-1, y,gridcol, (LS_BIGDASH << 8) | 1); - if ((y+gridsize) < map[curmap].height) { - drawline(buffer,0,y+gridsize,map[curmap].width-1, y+gridsize,gridcol, (LS_DOTTED << 8) | 1); - } + for (y = 0; y < map[curmap].height; y += (gridsize*2)) { + drawline(buffer,0,y,map[curmap].width-1, y,gridcol, (LS_BIGDASH << 8) | 1); + if ((y+gridsize) < map[curmap].height) { + drawline(buffer,0,y+gridsize,map[curmap].width-1, y+gridsize,gridcol, (LS_DOTTED << 8) | 1); } - - /* - for (y = 0; y < map[curmap].height; y += gridsize) { - for (x = 0; x < map[curmap].width; x += gridsize) { - drawpixel(buffer, x, y, gridcol); - } - } - */ } if (testing) { @@ -3966,6 +3955,19 @@ void drawtoolbox(void) { drawline(screen, area.x+(area.w/2)+3, area.y+(area.h/2)-3-4, area.x+(area.w/2)-3, area.y+(area.h/2)+3-4,white,1); } } + if (i == TB_GRID) { + if (grid) { + drawbox(screen, area.x+5,area.y+20,area.x + area.w - 15, area.y + area.h - 5, black, &black); + if (state == S_DRAWFLOW) { + drawbox(screen, area.x+area.w - 14,area.y+20,area.x + area.w - 7, area.y + area.h - 5, yellow, &yellow); + } else { + drawbox(screen, area.x+area.w - 14,area.y+20,area.x + area.w - 7, area.y + area.h - 5, green, &green); + } + } else { + drawbox(screen, area.x+5,area.y+20,area.x + area.w - 15, area.y + area.h - 5, red, &red); + drawbox(screen, area.x+area.w - 14,area.y+20,area.x + area.w - 7, area.y + area.h - 5, black, &black); + } + } if (i == TB_LINESTYLE) { int style; /* show line thickness */ @@ -5169,9 +5171,6 @@ int loadmap(void) { sprintf(statustext,"Successfully loaded map from '%s' (%d maps). [file version: '%s']\n",filename,nummaps, vers); strcpy(currentfilename, filename); - /* disable grid when we load a map */ - grid = FALSE; - updatewm(); drawmap(); @@ -7287,10 +7286,10 @@ void toggleflow(int oid, int otype) { void togglegrid(void) { if (grid) { grid = FALSE; - strcpy(statustext, "Grid mode disabled."); + strcpy(statustext, "Snap-To-Grid mode disabled."); } else { grid = TRUE; - strcpy(statustext, "Grid mode enabled."); + strcpy(statustext, "Snap-To-Grid mode enabled."); } }