diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2013-10-29 19:43:02 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2013-10-29 19:43:02 (GMT) |
| commit | f2e28ee66721f9db1a6fe93604a7db3cbcb71199 (patch) | |
| tree | 28fbf3648046e29110b61676d233e8890647e4fb /src/gui/game | |
| parent | e78dcae8517e3cc9efc4883935655d7098ab54b1 (diff) | |
| parent | 30d985ba7716238819185b96f811f7f6e5f4ffdb (diff) | |
| download | powder-f2e28ee66721f9db1a6fe93604a7db3cbcb71199.zip powder-f2e28ee66721f9db1a6fe93604a7db3cbcb71199.tar.gz | |
Merge branch 'feature_sparksigns' into develop
Diffstat (limited to 'src/gui/game')
| -rw-r--r-- | src/gui/game/GameController.cpp | 47 | ||||
| -rw-r--r-- | src/gui/game/GameController.h | 1 | ||||
| -rw-r--r-- | src/gui/game/SignTool.cpp | 10 |
3 files changed, 43 insertions, 15 deletions
diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index a114b82..cfcb5e6 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -253,6 +253,18 @@ GameView * GameController::GetView() return gameView; } +sign * GameController::GetSignAt(int x, int y){ + Simulation * sim = gameModel->GetSimulation(); + for (std::vector<sign>::iterator iter = sim->signs.begin(), end = sim->signs.end(); iter != end; ++iter) + { + int signx, signy, signw, signh; + (*iter).pos((*iter).getText(sim), signx, signy, signw, signh); + if (x>=signx && x<=signx+signw && y>=signy && y<=signy+signh) + return &(*iter); + } + return NULL; +} + void GameController::PlaceSave(ui::Point position) { if(gameModel->GetPlaceSave()) @@ -550,7 +562,18 @@ bool GameController::BrushChanged(int brushType, int rx, int ry) bool GameController::MouseDown(int x, int y, unsigned button) { - return commandInterface->OnMouseDown(x, y, button); + bool ret = commandInterface->OnMouseDown(x, y, button); + ui::Point point = PointTranslate(ui::Point(x, y)); + x = point.X; + y = point.Y; + if(ret && y<YRES && x<XRES) + if (gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking + { + sign * foundSign = GetSignAt(x, y); + if(foundSign && splitsign(foundSign->text.c_str())) + return false; + } + return ret; } bool GameController::MouseUp(int x, int y, unsigned button) @@ -563,17 +586,15 @@ bool GameController::MouseUp(int x, int y, unsigned button) { if (gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking { - Simulation * sim = gameModel->GetSimulation(); - for (std::vector<sign>::iterator iter = sim->signs.begin(), end = sim->signs.end(); iter != end; ++iter) - { - int signx, signy, signw, signh; - (*iter).pos((*iter).getText(sim), signx, signy, signw, signh); - if (x>=signx && x<=signx+signw && y>=signy && y<=signy+signh) + sign * foundSign = GetSignAt(x, y); + if(foundSign) { + const char* str=foundSign->text.c_str(); + char type; + int pos=splitsign(str, &type); + if (pos) { - const char* str=(*iter).text.c_str(); - int pos=splitsign(str); - if (pos) - { + ret = false; + if(type == 'c' || type == 't') { char buff[256]; strcpy(buff, str+3); buff[pos]=0; @@ -589,7 +610,9 @@ bool GameController::MouseUp(int x, int y, unsigned button) OpenURI(url); } } - break; + } else if(type == 'b') { + Simulation * sim = gameModel->GetSimulation(); + sim->create_part(-1, foundSign->x, foundSign->y, PT_SPRK); } } } diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h index b2a7d99..9fe3624 100644 --- a/src/gui/game/GameController.h +++ b/src/gui/game/GameController.h @@ -56,6 +56,7 @@ public: GameController(); ~GameController(); GameView * GetView(); + sign * GetSignAt(int x, int y); bool BrushChanged(int brushType, int rx, int ry); bool MouseMove(int x, int y, int dx, int dy); diff --git a/src/gui/game/SignTool.cpp b/src/gui/game/SignTool.cpp index 9cb389a..fdc1fb5 100644 --- a/src/gui/game/SignTool.cpp +++ b/src/gui/game/SignTool.cpp @@ -178,15 +178,19 @@ void SignWindow::DoDraw() { sign & currentSign = *iter; int x, y, w, h, dx, dy; + char type = 0; Graphics * g = ui::Engine::Ref().g; std::string text = currentSign.getText(sim); + splitsign(currentSign.text.c_str(), &type); 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 (splitsign(currentSign.text.c_str())) - g->drawtext(x+3, y+3, text, 0, 191, 255, 255); - else + if (!type) g->drawtext(x+3, y+3, text, 255, 255, 255, 255); + else if(type == 'b') + g->drawtext(x+3, y+3, text, 211, 211, 40, 255); + else + g->drawtext(x+3, y+3, text, 0, 191, 255, 255); x = currentSign.x; y = currentSign.y; |
