commit
68984bb9be
@ -285,7 +285,7 @@ if(GetOption('rpi')):
|
|||||||
|
|
||||||
if(GetOption('win')):
|
if(GetOption('win')):
|
||||||
openGLLibs = ['opengl32', 'glew32']
|
openGLLibs = ['opengl32', 'glew32']
|
||||||
env.Prepend(LIBS=['mingw32', 'ws2_32', 'SDLmain', 'SDL', 'regex'])
|
env.Prepend(LIBS=['mingw32', 'ws2_32', 'SDLmain', 'SDL'])
|
||||||
env.Append(CCFLAGS=['-std=gnu++98'])
|
env.Append(CCFLAGS=['-std=gnu++98'])
|
||||||
env.Append(LIBS=['winmm', 'gdi32'])
|
env.Append(LIBS=['winmm', 'gdi32'])
|
||||||
env.Append(CPPDEFINES=["WIN"])
|
env.Append(CPPDEFINES=["WIN"])
|
||||||
|
12
src/Misc.cpp
12
src/Misc.cpp
@ -2,7 +2,6 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <regex.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
@ -173,17 +172,6 @@ void clean_text(char *text, int vwidth)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 save_string(FILE *f, char *str)
|
void save_string(FILE *f, char *str)
|
||||||
{
|
{
|
||||||
int li = strlen(str);
|
int li = strlen(str);
|
||||||
|
@ -62,8 +62,6 @@ void load_presets(void);
|
|||||||
|
|
||||||
void save_string(FILE *f, char *str);
|
void save_string(FILE *f, char *str);
|
||||||
|
|
||||||
int sregexp(const char *str, char *pattern);
|
|
||||||
|
|
||||||
int load_string(FILE *f, char *str, int max);
|
int load_string(FILE *f, char *str, int max);
|
||||||
|
|
||||||
void strcaturl(char *dst, char *src);
|
void strcaturl(char *dst, char *src);
|
||||||
|
@ -912,7 +912,7 @@ void Renderer::DrawWalls()
|
|||||||
|
|
||||||
void Renderer::DrawSigns()
|
void Renderer::DrawSigns()
|
||||||
{
|
{
|
||||||
int i, j, x, y, w, h, dx, dy,mx,my,b=1,bq;
|
int i, j, x, y, w, h, dx, dy,mx,my,b=1,bq,match;
|
||||||
std::vector<sign> signs = sim->signs;
|
std::vector<sign> signs = sim->signs;
|
||||||
#ifdef OGLR
|
#ifdef OGLR
|
||||||
GLint prevFbo;
|
GLint prevFbo;
|
||||||
@ -923,14 +923,30 @@ void Renderer::DrawSigns()
|
|||||||
for (i=0; i < signs.size(); i++)
|
for (i=0; i < signs.size(); i++)
|
||||||
if (signs[i].text.length())
|
if (signs[i].text.length())
|
||||||
{
|
{
|
||||||
std::string text = sim->signs[i].getText(sim);
|
std::string text = signs[i].getText(sim);
|
||||||
sim->signs[i].pos(text, x, y, w, h);
|
const char* str = signs[i].text.c_str();
|
||||||
|
signs[i].pos(text, x, y, w, h);
|
||||||
clearrect(x, y, w+1, h);
|
clearrect(x, y, w+1, h);
|
||||||
drawrect(x, y, w+1, h, 192, 192, 192, 255);
|
drawrect(x, y, w+1, h, 192, 192, 192, 255);
|
||||||
if (sregexp(signs[i].text.c_str(), "^{[ct]:[0-9]*|.*}$"))
|
match=0;
|
||||||
drawtext(x+3, y+3, text, 255, 255, 255, 255);
|
// check if it's a link sign
|
||||||
else
|
if (str[0]=='{' && (str[1]=='c' || str[1]=='t') && str[2]==':' && str[3]>='0' && str[3]<='9')
|
||||||
|
{
|
||||||
|
const char* p=str+4;
|
||||||
|
while (*p>='0' && *p<='9')
|
||||||
|
p++;
|
||||||
|
if (*p=='|')
|
||||||
|
{
|
||||||
|
while (*p)
|
||||||
|
p++;
|
||||||
|
if (p[-1]=='}')
|
||||||
|
match=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (match)
|
||||||
drawtext(x+3, y+3, text, 0, 191, 255, 255);
|
drawtext(x+3, y+3, text, 0, 191, 255, 255);
|
||||||
|
else
|
||||||
|
drawtext(x+3, y+3, text, 255, 255, 255, 255);
|
||||||
|
|
||||||
x = signs[i].x;
|
x = signs[i].x;
|
||||||
y = signs[i].y;
|
y = signs[i].y;
|
||||||
|
@ -571,19 +571,30 @@ bool GameController::MouseUp(int x, int y, unsigned button)
|
|||||||
(*iter).pos((*iter).getText(sim), signx, signy, signw, signh);
|
(*iter).pos((*iter).getText(sim), signx, signy, signw, signh);
|
||||||
if (x>=signx && x<=signx+signw && y>=signy && y<=signy+signh)
|
if (x>=signx && x<=signx+signw && y>=signy && y<=signy+signh)
|
||||||
{
|
{
|
||||||
if (sregexp((*iter).text.c_str(), "^{[ct]:[0-9]*|.*}$")==0)
|
int match=0;
|
||||||
|
const char* str=(*iter).text.c_str();
|
||||||
|
const char* e;
|
||||||
|
if (str[0]=='{' && (str[1]=='c' || str[1]=='t') && str[2]==':' && str[3]>='0' && str[3]<='9')
|
||||||
|
{
|
||||||
|
const char* p=str+4;
|
||||||
|
while (*p>='0' && *p<='9')
|
||||||
|
p++;
|
||||||
|
e=p;
|
||||||
|
if (*p=='|')
|
||||||
|
{
|
||||||
|
while (*p)
|
||||||
|
p++;
|
||||||
|
if (p[-1]=='}')
|
||||||
|
{
|
||||||
|
match=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (match)
|
||||||
{
|
{
|
||||||
const char * signText = (*iter).text.c_str();
|
|
||||||
char buff[256];
|
char buff[256];
|
||||||
int sldr;
|
strcpy(buff, str+3);
|
||||||
|
buff[e-str-3]=0;
|
||||||
memset(buff, 0, sizeof(buff));
|
|
||||||
|
|
||||||
for (sldr=3; signText[sldr] != '|'; sldr++)
|
|
||||||
buff[sldr-3] = signText[sldr];
|
|
||||||
|
|
||||||
buff[sldr-3] = '\0';
|
|
||||||
|
|
||||||
int tempSaveID = format::StringToNumber<int>(std::string(buff));
|
int tempSaveID = format::StringToNumber<int>(std::string(buff));
|
||||||
if (tempSaveID)
|
if (tempSaveID)
|
||||||
{
|
{
|
||||||
|
@ -177,16 +177,30 @@ void SignWindow::DoDraw()
|
|||||||
for(std::vector<sign>::iterator iter = sim->signs.begin(), end = sim->signs.end(); iter != end; ++iter)
|
for(std::vector<sign>::iterator iter = sim->signs.begin(), end = sim->signs.end(); iter != end; ++iter)
|
||||||
{
|
{
|
||||||
sign & currentSign = *iter;
|
sign & currentSign = *iter;
|
||||||
int x, y, w, h, dx, dy;
|
int x, y, w, h, dx, dy, match=0;
|
||||||
Graphics * g = ui::Engine::Ref().g;
|
Graphics * g = ui::Engine::Ref().g;
|
||||||
std::string text = currentSign.getText(sim);
|
std::string text = currentSign.getText(sim);
|
||||||
|
const char* str = currentSign.text.c_str();
|
||||||
currentSign.pos(text, x, y, w, h);
|
currentSign.pos(text, x, y, w, h);
|
||||||
g->clearrect(x, y, w+1, h);
|
g->clearrect(x, y, w+1, h);
|
||||||
g->drawrect(x, y, w+1, h, 192, 192, 192, 255);
|
g->drawrect(x, y, w+1, h, 192, 192, 192, 255);
|
||||||
if (sregexp(currentSign.text.c_str(), "^{[ct]:[0-9]*|.*}$"))
|
if (str[0]=='{' && (str[1]=='c' || str[1]=='t') && str[2]==':' && str[3]>='0' && str[3]<='9')
|
||||||
g->drawtext(x+3, y+3, text, 255, 255, 255, 255);
|
{
|
||||||
else
|
const char* p=str+4;
|
||||||
|
while (*p>='0' && *p<='9')
|
||||||
|
p++;
|
||||||
|
if (*p=='|')
|
||||||
|
{
|
||||||
|
while (*p)
|
||||||
|
p++;
|
||||||
|
if (p[-1]=='}')
|
||||||
|
match=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (match)
|
||||||
g->drawtext(x+3, y+3, text, 0, 191, 255, 255);
|
g->drawtext(x+3, y+3, text, 0, 191, 255, 255);
|
||||||
|
else
|
||||||
|
g->drawtext(x+3, y+3, text, 255, 255, 255, 255);
|
||||||
|
|
||||||
x = currentSign.x;
|
x = currentSign.x;
|
||||||
y = currentSign.y;
|
y = currentSign.y;
|
||||||
|
@ -31,25 +31,38 @@ std::string sign::getText(Simulation *sim)
|
|||||||
else
|
else
|
||||||
sprintf(buff, "Temp: 0.00"); //...temperature
|
sprintf(buff, "Temp: 0.00"); //...temperature
|
||||||
}
|
}
|
||||||
else if (sregexp(signText, "^{[ct]:[0-9]*|.*}$")==0)
|
|
||||||
{
|
|
||||||
int sldr, startm;
|
|
||||||
memset(buff, 0, sizeof(buff));
|
|
||||||
for (sldr=3; signText[sldr-1] != '|'; sldr++)
|
|
||||||
startm = sldr + 1;
|
|
||||||
sldr = startm;
|
|
||||||
while (signText[sldr] != '}')
|
|
||||||
{
|
|
||||||
buff[sldr - startm] = signText[sldr];
|
|
||||||
sldr++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(buff, "%s", signText);
|
int match=0;
|
||||||
|
const char* r;
|
||||||
|
const char* e;
|
||||||
|
if (signText[0]=='{' && (signText[1]=='c' || signText[1]=='t') && signText[2]==':' && signText[3]>='0' && signText[3]<='9')
|
||||||
|
{
|
||||||
|
const char* p=signText+4;
|
||||||
|
while (*p>='0' && *p<='9')
|
||||||
|
p++;
|
||||||
|
if (*p=='|')
|
||||||
|
{
|
||||||
|
r=p+1;
|
||||||
|
while (*p)
|
||||||
|
p++;
|
||||||
|
if (p[-1]=='}')
|
||||||
|
{
|
||||||
|
match=1;
|
||||||
|
e=p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (match)
|
||||||
|
{
|
||||||
|
strcpy(buff, r);
|
||||||
|
buff[e-r-1]=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strcpy(buff, signText);
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string(buff,256);
|
return std::string(buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sign::pos(std::string signText, int & x0, int & y0, int & w, int & h)
|
void sign::pos(std::string signText, int & x0, int & y0, int & w, int & h)
|
||||||
|
Loading…
Reference in New Issue
Block a user