ALL GLORY TO THE SAVASK

This commit is contained in:
Simon 2011-01-31 16:54:13 +00:00
parent 61292f5355
commit 8363a21f23
5 changed files with 79 additions and 3 deletions

View File

@ -59,6 +59,8 @@ void load_presets(void);
void save_string(FILE *f, char *str);
int sregexp(const char *str, char *pattern);
int load_string(FILE *f, char *str, int max);
void strcaturl(char *dst, char *src);

View File

@ -2885,10 +2885,10 @@ void draw_parts(pixel *vid)
void render_signs(pixel *vid_buf)
{
int i, j, x, y, w, h, dx, dy,mx,my,b=1,bq;
char buff[30]; //Buffer
for (i=0; i<MAXSIGNS; i++)
if (signs[i].text[0])
{
char buff[256]; //Buffer
get_sign_pos(i, &x, &y, &w, &h);
clearrect(vid_buf, x, y, w, h);
drawrect(vid_buf, x, y, w, h, 192, 192, 192, 255);
@ -2907,9 +2907,24 @@ void render_signs(pixel *vid_buf)
sprintf(buff, "Temp: 0.00"); //...tempirature
drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255);
}
if(sregexp(signs[i].text, "^{c:[0-9]*|.*}$")==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, 191, 255, 255);
}
//Usual text
if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}"))
if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$"))
drawtext(vid_buf, x+3, y+3, signs[i].text, 255, 255, 255, 255);
x = signs[i].x;

View File

@ -89,8 +89,25 @@ void get_sign_pos(int i, int *x0, int *y0, int *w, int *h)
if (strcmp(signs[i].text, "{t}")==0)
*w = textwidth("Temp: 0000.00");
if(sregexp(signs[i].text, "^{c:[0-9]*|.*}$")==0)
{
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}"))
if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$"))
*w = textwidth(signs[i].text) + 5;
*h = 14;
*x0 = (signs[i].ju == 2) ? signs[i].x - *w :

View File

@ -2407,8 +2407,37 @@ int main(int argc, char *argv[])
}
else if (y<YRES)
{
int signi;
c = (b&1) ? sl : sr;
su = c;
if(c!=WL_SIGN+100)
{
if(!bq)
for(signi=0; signi<MAXSIGNS; signi++)
if(sregexp(signs[signi].text, "^{c:[0-9]*|.*}$")==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);
open_ui(vid_buf, buff2, 0);
}
}
}
if (c==WL_SIGN+100)
{
if (!bq)

View File

@ -1,6 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <regex.h>
#include <sys/types.h>
#include "misc.h"
#include "defines.h"
#include "interface.h"
@ -116,6 +118,17 @@ void save_presets(int do_update)
fclose(f);
}
int sregexp(const char *str, char *pattern)
{
int result;
regex_t patternc;
if(regcomp(&patternc, pattern, 0)!=0)
return 1;
result = regexec(&patternc, str, 0, NULL, 0);
regfree(&patternc);
return result;
}
void load_presets(void)
{
FILE *f=fopen("powder.def", "rb");