summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authormniip <mniip@mniip.com>2013-08-22 15:50:20 (GMT)
committer mniip <mniip@mniip.com>2013-08-22 15:50:20 (GMT)
commite2cb5838c6b89bf0f34aa08562d3e3763729cba6 (patch)
treea627d039c8cf9952a9843fb11da690e6ab61f1f2 /src/gui
parent4a308cbf661bb40efdf53c6632f875c6c393a307 (diff)
downloadpowder-e2cb5838c6b89bf0f34aa08562d3e3763729cba6.zip
powder-e2cb5838c6b89bf0f34aa08562d3e3763729cba6.tar.gz
specially per @savask's request, put matcher into a function
returns 0 if no match, returns position of pipe character if there is
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/game/GameController.cpp23
-rw-r--r--src/gui/game/SignTool.cpp18
2 files changed, 5 insertions, 36 deletions
diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp
index c514d3e..539b084 100644
--- a/src/gui/game/GameController.cpp
+++ b/src/gui/game/GameController.cpp
@@ -571,30 +571,13 @@ bool GameController::MouseUp(int x, int y, unsigned button)
(*iter).pos((*iter).getText(sim), signx, signy, signw, signh);
if (x>=signx && x<=signx+signw && y>=signy && y<=signy+signh)
{
- 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)
+ int pos=splitsign(str);
+ if (pos)
{
char buff[256];
strcpy(buff, str+3);
- buff[e-str-3]=0;
+ buff[pos]=0;
int tempSaveID = format::StringToNumber<int>(std::string(buff));
if (tempSaveID)
{
diff --git a/src/gui/game/SignTool.cpp b/src/gui/game/SignTool.cpp
index a71f8e2..9cb389a 100644
--- a/src/gui/game/SignTool.cpp
+++ b/src/gui/game/SignTool.cpp
@@ -177,27 +177,13 @@ void SignWindow::DoDraw()
for(std::vector<sign>::iterator iter = sim->signs.begin(), end = sim->signs.end(); iter != end; ++iter)
{
sign & currentSign = *iter;
- int x, y, w, h, dx, dy, match=0;
+ int x, y, w, h, dx, dy;
Graphics * g = ui::Engine::Ref().g;
std::string text = currentSign.getText(sim);
- const char* str = currentSign.text.c_str();
currentSign.pos(text, x, y, w, h);
g->clearrect(x, y, w+1, h);
g->drawrect(x, y, w+1, h, 192, 192, 192, 255);
- 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)
+ if (splitsign(currentSign.text.c_str()))
g->drawtext(x+3, y+3, text, 0, 191, 255, 255);
else
g->drawtext(x+3, y+3, text, 255, 255, 255, 255);