regexless gameModel
This commit is contained in:
parent
95c01bcf0a
commit
4e9fe8b8e7
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user