From b08c37342b4e1925776451d0ca7388cb5841d432 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Mon, 14 Feb 2011 20:32:01 -0500 Subject: [PATCH] Commands in signs, some don't fit --- src/graphics.c | 16 +++++++++++++++- src/interface.c | 18 +++++++++++++++++- src/main.c | 22 ++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/graphics.c b/src/graphics.c index 78f1867fb..29aa3ebc1 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -2961,9 +2961,23 @@ void render_signs(pixel *vid_buf) } drawtext(vid_buf, x+3, y+3, buff, 0, 191, 255, 255); } + if(sregexp(signs[i].text, "^{e:.*|.*}$")==0) + { + int sldr, startm; + memset(buff, 0, sizeof(buff)); + for(sldr=3; signs[i].text[sldr-1] != '|'; sldr++) + startm = sldr + 1; + sldr = startm; + while(signs[i].text[sldr] != '}') + { + buff[sldr - startm] = signs[i].text[sldr]; + sldr++; + } + drawtext(vid_buf, x+3, y+3, buff, 0, 255, 215, 255); + } //Usual text - if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$")) + if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$") && sregexp(signs[i].text, "^{e:.*|.*}$")) drawtext(vid_buf, x+3, y+3, signs[i].text, 255, 255, 255, 255); x = signs[i].x; diff --git a/src/interface.c b/src/interface.c index 32c83a18b..07616926e 100644 --- a/src/interface.c +++ b/src/interface.c @@ -105,9 +105,25 @@ void get_sign_pos(int i, int *x0, int *y0, int *w, int *h) } *w = textwidth(buff) + 5; } + if(sregexp(signs[i].text, "^{e:.*|.*}$")==0)//character width limit in signs need to be incresed, as most commands don't fit.. + { + int sldr, startm; + char buff[256]; + memset(buff, 0, sizeof(buff)); + for(sldr=3; signs[i].text[sldr-1] != '|'; sldr++) + startm = sldr + 1; + + sldr = startm; + while(signs[i].text[sldr] != '}') + { + buff[sldr - startm] = signs[i].text[sldr]; + sldr++; + } + *w = textwidth(buff) + 5; + } //Ususal width - if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$")) + if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$") && sregexp(signs[i].text, "^{e:.*|.*}$")) *w = textwidth(signs[i].text) + 5; *h = 14; *x0 = (signs[i].ju == 2) ? signs[i].x - *w : diff --git a/src/main.c b/src/main.c index bb2747323..568b07002 100644 --- a/src/main.c +++ b/src/main.c @@ -2353,6 +2353,7 @@ int main(int argc, char *argv[]) { if(!bq) for(signi=0; signi=signx && x<=signx+signw && y>=signy && y<=signy+signh) + { + char buff[256]; + int sldr; + + memset(buff, 0, sizeof(buff)); + + for(sldr=3; signs[signi].text[sldr] != '|'; sldr++) + buff[sldr-3] = signs[signi].text[sldr]; + + char buff2[sldr-2]; //TODO: Fix this for Visual Studio + memset(buff2, 0, sizeof(buff2)); + memcpy(&buff2, &buff, sldr-3); + process_command(vid_buf, buff2,console_error); + } + } + } } if (c==WL_SIGN+100)