diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-05-13 16:43:41 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-05-13 16:43:41 (GMT) |
| commit | 4032a0469b1f40f7197468f34986e365bd6e7314 (patch) | |
| tree | f324519139168068628f8d6e0fc8046001c9c0a1 /src/game | |
| parent | a2e91c247fab4a2cee8936d83979f4a72390f7e7 (diff) | |
| download | powder-4032a0469b1f40f7197468f34986e365bd6e7314.zip powder-4032a0469b1f40f7197468f34986e365bd6e7314.tar.gz | |
Click function for tools that aren't continuous. Debug helper for UI components (Ctrl+Shift D when DEBUG is defined), fix add sign window logic
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/GameController.cpp | 10 | ||||
| -rw-r--r-- | src/game/GameController.h | 1 | ||||
| -rw-r--r-- | src/game/GameView.cpp | 1 | ||||
| -rw-r--r-- | src/game/SignTool.cpp | 15 | ||||
| -rw-r--r-- | src/game/Tool.h | 10 |
5 files changed, 21 insertions, 16 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 529137a..7f852a6 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -304,6 +304,16 @@ void GameController::DrawPoints(int toolSelection, queue<ui::Point*> & pointQueu } } +void GameController::ToolClick(int toolSelection, ui::Point point) +{ + Simulation * sim = gameModel->GetSimulation(); + Tool * activeTool = gameModel->GetActiveTool(toolSelection); + Brush * cBrush = gameModel->GetBrush(); + if(!activeTool || !cBrush) + return; + activeTool->Click(sim, cBrush, PointTranslate(point)); +} + void GameController::StampRegion(ui::Point point1, ui::Point point2) { int saveSize; diff --git a/src/game/GameController.h b/src/game/GameController.h index 8f49668..bb6e61a 100644 --- a/src/game/GameController.h +++ b/src/game/GameController.h @@ -63,6 +63,7 @@ public: void SetZoomPosition(ui::Point position); void AdjustBrushSize(int direction, bool logarithmic = false); void AdjustZoomSize(int direction, bool logarithmic = false); + void ToolClick(int toolSelection, ui::Point point); void DrawPoints(int toolSelection, queue<ui::Point*> & pointQueue); void DrawRect(int toolSelection, ui::Point point1, ui::Point point2); void DrawLine(int toolSelection, ui::Point point1, ui::Point point2); diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index cfc6a19..c05ca12 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -599,6 +599,7 @@ void GameView::OnMouseUp(int x, int y, unsigned button) } if(drawMode == DrawPoints) { + c->ToolClick(toolIndex, ui::Point(x, y)); pointQueue.push(new ui::Point(x, y)); } if(drawModeReset) diff --git a/src/game/SignTool.cpp b/src/game/SignTool.cpp index 50ddb8a..fa004a8 100644 --- a/src/game/SignTool.cpp +++ b/src/game/SignTool.cpp @@ -26,17 +26,16 @@ public: OkayAction(SignWindow * prompt_) { prompt = prompt_; } void ActionCallback(ui::Button * sender) { - ui::Engine::Ref().CloseWindow(); - prompt->SelfDestruct(); - + ui::Engine::Ref().CloseWindow(); if(prompt->signID==-1 && prompt->textField->GetText().length()) { prompt->sim->signs.push_back(sign(prompt->textField->GetText(), prompt->signPosition.X, prompt->signPosition.Y, sign::Left)); } - else + else if(prompt->textField->GetText().length()) { prompt->sim->signs[prompt->signID] = sign(sign(prompt->textField->GetText(), prompt->signPosition.X, prompt->signPosition.Y, sign::Left)); } + prompt->SelfDestruct(); } }; @@ -71,11 +70,7 @@ void SignWindow::OnDraw() g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); } -void SignTool::Draw(Simulation * sim, Brush * brush, ui::Point position) +void SignTool::Click(Simulation * sim, Brush * brush, ui::Point position) { - if(!opened) //Ensure the dialogue can only be shown one at a time. - { - opened = true; - new SignWindow(this, sim, -1, position); - } + new SignWindow(this, sim, -1, position); }
\ No newline at end of file diff --git a/src/game/Tool.h b/src/game/Tool.h index 935e598..3a66ae4 100644 --- a/src/game/Tool.h +++ b/src/game/Tool.h @@ -28,6 +28,7 @@ public: } string GetName() { return toolName; } virtual ~Tool() {} + virtual void Click(Simulation * sim, Brush * brush, ui::Point position) { } virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) { sim->ToolBrush(position.X, position.Y, toolID, brush); } @@ -45,18 +46,15 @@ class SignTool: public Tool { public: SignTool(): - Tool(0, "SIGN", 0, 0, 0), - opened(false) + Tool(0, "SIGN", 0, 0, 0) { } virtual ~SignTool() {} - virtual void Draw(Simulation * sim, Brush * brush, ui::Point position); + virtual void Click(Simulation * sim, Brush * brush, ui::Point position); + virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) { } virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { } virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { } virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) { } - void SetClosed() { opened = false; } -protected: - bool opened; }; class PropertyTool: public Tool |
