- Fixed various text positioning/sizing bugs
- Text anchored to the selected object will now be highlighted in green
This commit is contained in:
parent
44fd48997e
commit
c1e00f9fdd
73
netmapr.c
73
netmapr.c
|
@ -1657,6 +1657,8 @@ void drawmap(void) {
|
||||||
/* by drawing boxes in its corners */
|
/* by drawing boxes in its corners */
|
||||||
if (map[curmap].selecteditem != -1) {
|
if (map[curmap].selecteditem != -1) {
|
||||||
if (map[curmap].selecteditemtype == T_OBJECT) {
|
if (map[curmap].selecteditemtype == T_OBJECT) {
|
||||||
|
int n;
|
||||||
|
|
||||||
/* 10% of map[curmap].object's size */
|
/* 10% of map[curmap].object's size */
|
||||||
area.w = map[curmap].obj[map[curmap].selecteditem].w / OBJSELHANDLEPCT;
|
area.w = map[curmap].obj[map[curmap].selecteditem].w / OBJSELHANDLEPCT;
|
||||||
area.h = map[curmap].obj[map[curmap].selecteditem].h / OBJSELHANDLEPCT;
|
area.h = map[curmap].obj[map[curmap].selecteditem].h / OBJSELHANDLEPCT;
|
||||||
|
@ -1677,10 +1679,56 @@ void drawmap(void) {
|
||||||
/* bottom right */
|
/* bottom right */
|
||||||
area.x = map[curmap].obj[map[curmap].selecteditem].x + map[curmap].obj[map[curmap].selecteditem].w - area.w; area.y = map[curmap].obj[map[curmap].selecteditem].y + map[curmap].obj[map[curmap].selecteditem].h - area.h;
|
area.x = map[curmap].obj[map[curmap].selecteditem].x + map[curmap].obj[map[curmap].selecteditem].w - area.w; area.y = map[curmap].obj[map[curmap].selecteditem].y + map[curmap].obj[map[curmap].selecteditem].h - area.h;
|
||||||
SDL_FillRect(buffer, &area, fillcol);
|
SDL_FillRect(buffer, &area, fillcol);
|
||||||
|
|
||||||
|
/* Also highlight any text anchored to this object */
|
||||||
|
for (n = 0; n < map[curmap].numtext; n++) {
|
||||||
|
if (map[curmap].textob[n].anchor == map[curmap].selecteditem) {
|
||||||
|
int th;
|
||||||
|
|
||||||
|
/* calculate text's height */
|
||||||
|
th = TTF_FontHeight(font[map[curmap].textob[n].h]);
|
||||||
|
|
||||||
|
/* 10% of text's size */
|
||||||
|
area.w = map[curmap].textob[n].w / OBJSELHANDLEPCT;
|
||||||
|
area.h = th / OBJSELHANDLEPCT;
|
||||||
|
if (area.w < 2) area.w = 2;
|
||||||
|
if (area.h < 2) area.h = 2;
|
||||||
|
|
||||||
|
anchoreditem = map[curmap].textob[n].anchor;
|
||||||
|
if (anchoreditem == -1) {
|
||||||
|
txoff = 0;
|
||||||
|
tyoff = 0;
|
||||||
|
} else {
|
||||||
|
txoff = map[curmap].obj[anchoreditem].x;
|
||||||
|
tyoff = map[curmap].obj[anchoreditem].y;
|
||||||
|
}
|
||||||
|
|
||||||
|
fillcol = SDL_MapRGB(buffer->format, 0, 255, 0);
|
||||||
|
|
||||||
|
/* top left */
|
||||||
|
area.x = map[curmap].textob[n].x + txoff; area.y = map[curmap].textob[n].y + tyoff;
|
||||||
|
SDL_FillRect(buffer, &area, fillcol);
|
||||||
|
/* top right */
|
||||||
|
area.x = map[curmap].textob[n].x +txoff + map[curmap].textob[n].w - area.w; area.y = map[curmap].textob[n].y + tyoff;
|
||||||
|
SDL_FillRect(buffer, &area, fillcol);
|
||||||
|
/* bottom left */
|
||||||
|
area.x = map[curmap].textob[n].x +txoff ; area.y = map[curmap].textob[n].y + tyoff + th - area.h;
|
||||||
|
SDL_FillRect(buffer, &area, fillcol);
|
||||||
|
/* bottom right */
|
||||||
|
area.x = map[curmap].textob[n].x+txoff + map[curmap].textob[n].w - area.w; area.y = map[curmap].textob[n].y +tyoff+ th - area.h;
|
||||||
|
SDL_FillRect(buffer, &area, fillcol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (map[curmap].selecteditemtype == T_TEXT) {
|
} else if (map[curmap].selecteditemtype == T_TEXT) {
|
||||||
|
int th;
|
||||||
|
|
||||||
|
/* calculate text's height */
|
||||||
|
th = TTF_FontHeight(font[map[curmap].textob[map[curmap].selecteditem].h]);
|
||||||
|
|
||||||
/* 10% of text's size */
|
/* 10% of text's size */
|
||||||
area.w = map[curmap].textob[map[curmap].selecteditem].w / OBJSELHANDLEPCT;
|
area.w = map[curmap].textob[map[curmap].selecteditem].w / OBJSELHANDLEPCT;
|
||||||
area.h = map[curmap].textob[map[curmap].selecteditem].h / OBJSELHANDLEPCT;
|
area.h = th / OBJSELHANDLEPCT;
|
||||||
if (area.w < 2) area.w = 2;
|
if (area.w < 2) area.w = 2;
|
||||||
if (area.h < 2) area.h = 2;
|
if (area.h < 2) area.h = 2;
|
||||||
|
|
||||||
|
@ -1702,10 +1750,10 @@ void drawmap(void) {
|
||||||
area.x = map[curmap].textob[map[curmap].selecteditem].x +txoff + map[curmap].textob[map[curmap].selecteditem].w - area.w; area.y = map[curmap].textob[map[curmap].selecteditem].y + tyoff;
|
area.x = map[curmap].textob[map[curmap].selecteditem].x +txoff + map[curmap].textob[map[curmap].selecteditem].w - area.w; area.y = map[curmap].textob[map[curmap].selecteditem].y + tyoff;
|
||||||
SDL_FillRect(buffer, &area, fillcol);
|
SDL_FillRect(buffer, &area, fillcol);
|
||||||
/* bottom left */
|
/* bottom left */
|
||||||
area.x = map[curmap].textob[map[curmap].selecteditem].x +txoff ; area.y = map[curmap].textob[map[curmap].selecteditem].y + tyoff +map[curmap].textob[map[curmap].selecteditem].h - area.h;
|
area.x = map[curmap].textob[map[curmap].selecteditem].x +txoff ; area.y = map[curmap].textob[map[curmap].selecteditem].y + tyoff + th - area.h;
|
||||||
SDL_FillRect(buffer, &area, fillcol);
|
SDL_FillRect(buffer, &area, fillcol);
|
||||||
/* bottom right */
|
/* bottom right */
|
||||||
area.x = map[curmap].textob[map[curmap].selecteditem].x+txoff + map[curmap].textob[map[curmap].selecteditem].w - area.w; area.y = map[curmap].textob[map[curmap].selecteditem].y +tyoff+ map[curmap].textob[map[curmap].selecteditem].h - area.h;
|
area.x = map[curmap].textob[map[curmap].selecteditem].x+txoff + map[curmap].textob[map[curmap].selecteditem].w - area.w; area.y = map[curmap].textob[map[curmap].selecteditem].y +tyoff+ th - area.h;
|
||||||
SDL_FillRect(buffer, &area, fillcol);
|
SDL_FillRect(buffer, &area, fillcol);
|
||||||
|
|
||||||
/* if this text is anchored, highlight the map[curmap].object which it is anchored to */
|
/* if this text is anchored, highlight the map[curmap].object which it is anchored to */
|
||||||
|
@ -1730,6 +1778,7 @@ void drawmap(void) {
|
||||||
area.x = map[curmap].obj[anchoreditem].x + map[curmap].obj[anchoreditem].w - area.w; area.y = map[curmap].obj[anchoreditem].y + map[curmap].obj[anchoreditem].h - area.h;
|
area.x = map[curmap].obj[anchoreditem].x + map[curmap].obj[anchoreditem].w - area.w; area.y = map[curmap].obj[anchoreditem].y + map[curmap].obj[anchoreditem].h - area.h;
|
||||||
SDL_FillRect(buffer, &area, fillcol);
|
SDL_FillRect(buffer, &area, fillcol);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (map[curmap].selecteditemtype == T_LINK) {
|
} else if (map[curmap].selecteditemtype == T_LINK) {
|
||||||
/* 10% of map[curmap].object's size */
|
/* 10% of map[curmap].object's size */
|
||||||
area.w = LINESELHANDLESIZE;
|
area.w = LINESELHANDLESIZE;
|
||||||
|
@ -1783,11 +1832,6 @@ void drawmap(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testing) {
|
|
||||||
printf("BLIT BUFFER TO SCREEN\n"); fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* blit buffer to screen */
|
/* blit buffer to screen */
|
||||||
SDL_BlitSurface(buffer, 0, screen,0);
|
SDL_BlitSurface(buffer, 0, screen,0);
|
||||||
|
|
||||||
|
@ -3629,7 +3673,7 @@ int isonmapbox(int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int isonmapboxchildren(int x, int y) {
|
int isonmapboxchildren(int x, int y) {
|
||||||
if ((x >= mapbox.x) && ( y >= mapbox.y+(DEFTEXTH*2)+2) && (x <= mapbox.x+mapbox.width) && (y <= mapbox.y+mapbox.height)) {
|
if ((x >= mapbox.x) && ( y >= mapbox.y+(TTF_FontHeight(font[MAPBOXTEXTHEIGHT])*2)+2) && (x <= mapbox.x+mapbox.width) && (y <= mapbox.y+mapbox.height)) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -3642,8 +3686,8 @@ int isonmapname(int x, int y) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
int isongoback(int x, int y) {
|
int isongoback(int x, int y) {
|
||||||
if ((x >= mapbox.x) && ( y >= (mapbox.y + DEFTEXTH))
|
if ((x >= mapbox.x) && ( y >= (mapbox.y + TTF_FontHeight(font[MAPBOXTEXTHEIGHT])))
|
||||||
&& (x <= mapbox.x+mapbox.width) && (y <= mapbox.y+(DEFTEXTH*2))) {
|
&& (x <= mapbox.x+mapbox.width) && (y <= mapbox.y+(TTF_FontHeight(font[MAPBOXTEXTHEIGHT])*2))) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -5028,13 +5072,8 @@ int endtextresize(int x, int y) {
|
||||||
tp = map[curmap].textob[map[curmap].curtext].text;
|
tp = map[curmap].textob[map[curmap].curtext].text;
|
||||||
TTF_SizeText(font[newh], tp, &tw, &th);
|
TTF_SizeText(font[newh], tp, &tw, &th);
|
||||||
|
|
||||||
//if (map[curmap].textob[map[curmap].curtext].w + tw > 0) {
|
neww = tw;
|
||||||
neww = tw;
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (neww < strlen(map[curmap].textob[map[curmap].curtext].text) * MINLETTERWIDTH) neww = strlen(map[curmap].textob[map[curmap].curtext].text) * MINLETTERWIDTH;
|
|
||||||
|
|
||||||
if (neww > strlen(map[curmap].textob[map[curmap].curtext].text) * MAXLETTERWIDTH ) neww = strlen(map[curmap].textob[map[curmap].curtext].text) * MAXLETTERWIDTH;
|
|
||||||
if ((map[curmap].textob[map[curmap].curtext].x + neww) >= map[curmap].width ) neww = map[curmap].width - map[curmap].textob[map[curmap].curtext].x - 1;
|
if ((map[curmap].textob[map[curmap].curtext].x + neww) >= map[curmap].width ) neww = map[curmap].width - map[curmap].textob[map[curmap].curtext].x - 1;
|
||||||
|
|
||||||
map[curmap].textob[map[curmap].curtext].w = neww;
|
map[curmap].textob[map[curmap].curtext].w = neww;
|
||||||
|
|
Loading…
Reference in New Issue