From 71db872e6422dd264ffa00a848d3f8a76e08b279 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 2 Oct 2012 21:31:39 -0400 Subject: [PATCH] {t:15100|text} to open a forum thread (will try to add more shortcuts later) --- src/game/GameController.cpp | 15 ++++++++++++--- src/game/SignTool.cpp | 2 +- src/graphics/Renderer.cpp | 2 +- src/simulation/Sign.cpp | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 8ba215e90..1fd813c32 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -536,7 +536,7 @@ bool GameController::MouseUp(int x, int y, unsigned button) (*iter).pos(signx, signy, signw, signh); if (x>=signx && x<=signx+signw && y>=signy && y<=signy+signh) { - if (sregexp((*iter).text.c_str(), "^{c:[0-9]*|.*}$")==0) + if (sregexp((*iter).text.c_str(), "^{[c|t]:[0-9]*|.*}$")==0) { const char * signText = (*iter).text.c_str(); char buff[256]; @@ -550,8 +550,17 @@ bool GameController::MouseUp(int x, int y, unsigned button) buff[sldr-3] = '\0'; int tempSaveID = format::StringToNumber(std::string(buff)); - if(tempSaveID) - OpenSavePreview(tempSaveID, 0); + if (tempSaveID) + { + if ((*iter).text.c_str()[1] == 'c') + OpenSavePreview(tempSaveID, 0); + else if ((*iter).text.c_str()[1] == 't') + { + char url[256]; + sprintf(url, "http://powdertoy.co.uk/Discussions/Thread/View.html?Thread=%i", tempSaveID); + OpenURI(url); + } + } break; } } diff --git a/src/game/SignTool.cpp b/src/game/SignTool.cpp index 4a5fc6918..eb1ef5734 100644 --- a/src/game/SignTool.cpp +++ b/src/game/SignTool.cpp @@ -199,7 +199,7 @@ void SignWindow::DoDraw() sprintf(buff, "Temp: 0.00"); //...temperature g->drawtext(x+3, y+3, buff, 255, 255, 255, 255); } - else if (sregexp(currentSign.text.c_str(), "^{c:[0-9]*|.*}$")==0) + else if (sregexp(currentSign.text.c_str(), "^{[c|t]:[0-9]*|.*}$")==0) { int sldr, startm; memset(buff, 0, sizeof(buff)); diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index f20d442b2..95a44d85e 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -848,7 +848,7 @@ void Renderer::DrawSigns() sprintf(buff, "Temp: 0.00"); //...temperature drawtext(x+3, y+3, buff, 255, 255, 255, 255); } - else if (sregexp(signs[i].text.c_str(), "^{c:[0-9]*|.*}$")==0) + else if (sregexp(signs[i].text.c_str(), "^{[c|t]:[0-9]*|.*}$")==0) { int sldr, startm; memset(buff, 0, sizeof(buff)); diff --git a/src/simulation/Sign.cpp b/src/simulation/Sign.cpp index 01d388f7f..2caf6c3de 100644 --- a/src/simulation/Sign.cpp +++ b/src/simulation/Sign.cpp @@ -28,7 +28,7 @@ void sign::pos(int & x0, int & y0, int & w, int & h) { w = Graphics::textwidth("Temp: 0000.00"); } - else if (sregexp(text.c_str(), "^{c:[0-9]*|.*}$")==0) + else if (sregexp(text.c_str(), "^{[c|t]:[0-9]*|.*}$")==0) { int sldr, startm; char buff[256];