Commands in signs, some don't fit

This commit is contained in:
Cracker64 2011-02-14 20:32:01 -05:00
parent e882dfecf9
commit b08c37342b
3 changed files with 54 additions and 2 deletions

View File

@ -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;

View File

@ -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 :

View File

@ -2353,6 +2353,7 @@ int main(int argc, char *argv[])
{
if(!bq)
for(signi=0; signi<MAXSIGNS; signi++)
{
if(sregexp(signs[signi].text, "^{c:[0-9]*|.*}$")==0)
{
int signx, signy, signw, signh;
@ -2373,6 +2374,27 @@ int main(int argc, char *argv[])
open_ui(vid_buf, buff2, 0);
}
}
if(sregexp(signs[signi].text, "^{e:.*|.*}$")==0)
{
int signx, signy, signw, signh;
get_sign_pos(signi, &signx, &signy, &signw, &signh);
if(x>=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)