diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 1675b524c..a5ccb866c 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -422,7 +422,7 @@ void GameController::DrawRect(int toolSelection, ui::Point point1, ui::Point poi Brush * cBrush = gameModel->GetBrush(); if(!activeTool || !cBrush) return; - activeTool->SetStrength(gameModel->GetToolStrength()); + activeTool->SetStrength(1.0f); activeTool->DrawRect(sim, cBrush, point1, point2); } @@ -434,7 +434,7 @@ void GameController::DrawLine(int toolSelection, ui::Point point1, ui::Point poi Brush * cBrush = gameModel->GetBrush(); if(!activeTool || !cBrush) return; - activeTool->SetStrength(gameModel->GetToolStrength()); + activeTool->SetStrength(1.0f); activeTool->DrawLine(sim, cBrush, point1, point2); } @@ -446,7 +446,7 @@ void GameController::DrawFill(int toolSelection, ui::Point point) Brush * cBrush = gameModel->GetBrush(); if(!activeTool || !cBrush) return; - activeTool->SetStrength(gameModel->GetToolStrength()); + activeTool->SetStrength(1.0f); activeTool->DrawFill(sim, cBrush, point); } diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 66e478799..de2d44837 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -1101,9 +1101,9 @@ void GameView::OnMouseDown(int x, int y, unsigned button) button = BUTTON_MIDDLE; if (!(zoomEnabled && !zoomCursorFixed)) { - isMouseDown = true; if (selectMode != SelectNone) { + isMouseDown = true; if (button == BUTTON_LEFT && selectPoint1.X == -1) { selectPoint1 = c->PointTranslate(currentMouse); @@ -1119,6 +1119,7 @@ void GameView::OnMouseDown(int x, int y, unsigned button) toolIndex = 1; if (button == BUTTON_MIDDLE) toolIndex = 2; + isMouseDown = true; c->HistorySnapshot(); if (drawMode == DrawRect || drawMode == DrawLine) { @@ -1890,33 +1891,29 @@ void GameView::NotifyPlaceSaveChanged(GameModel * sender) void GameView::enableShiftBehaviour() { - if(!shiftBehaviour) + if (!shiftBehaviour) { shiftBehaviour = true; if (!isMouseDown || selectMode != SelectNone) UpdateDrawMode(); - else if (toolBrush && drawMode == DrawPoints) - c->SetToolStrength(10.0f); + UpdateToolStrength(); } } void GameView::disableShiftBehaviour() { - if(shiftBehaviour) + if (shiftBehaviour) { shiftBehaviour = false; if (!isMouseDown || selectMode != SelectNone) UpdateDrawMode(); - if (!ctrlBehaviour) - c->SetToolStrength(1.0f); - else - c->SetToolStrength(.1f); + UpdateToolStrength(); } } void GameView::enableAltBehaviour() { - if(!altBehaviour) + if (!altBehaviour) { altBehaviour = true; drawSnap = true; @@ -1934,11 +1931,12 @@ void GameView::disableAltBehaviour() void GameView::enableCtrlBehaviour() { - if(!ctrlBehaviour) + if (!ctrlBehaviour) { ctrlBehaviour = true; if (!isMouseDown || selectMode != SelectNone) UpdateDrawMode(); + UpdateToolStrength(); //Show HDD save & load buttons saveSimulationButton->Appearance.BackgroundInactive = saveSimulationButton->Appearance.BackgroundHover = ui::Colour(255, 255, 255); @@ -1953,23 +1951,17 @@ void GameView::enableCtrlBehaviour() searchButton->SetToolTip("Open a simulation from your hard drive."); if (currentSaveType == 2) ((SplitButton*)saveSimulationButton)->SetShowSplit(true); - if ((isMouseDown && selectMode == SelectNone) || (toolBrush && drawMode == DrawPoints)) - { - if(!shiftBehaviour) - c->SetToolStrength(.1f); - else - c->SetToolStrength(10.0f); - } } } void GameView::disableCtrlBehaviour() { - if(ctrlBehaviour) + if (ctrlBehaviour) { ctrlBehaviour = false; if (!isMouseDown || selectMode != SelectNone) UpdateDrawMode(); + UpdateToolStrength(); //Hide HDD save & load buttons saveSimulationButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0); @@ -1983,10 +1975,6 @@ void GameView::disableCtrlBehaviour() searchButton->SetToolTip("Find & open a simulation. Hold Ctrl to load offline saves."); if (currentSaveType == 2) ((SplitButton*)saveSimulationButton)->SetShowSplit(false); - if(!shiftBehaviour) - c->SetToolStrength(1.0f); - else - c->SetToolStrength(10.0f); } } @@ -2007,6 +1995,16 @@ void GameView::UpdateDrawMode() drawMode = DrawPoints; } +void GameView::UpdateToolStrength() +{ + if (shiftBehaviour) + c->SetToolStrength(10.0f); + else if (ctrlBehaviour) + c->SetToolStrength(.1f); + else + c->SetToolStrength(1.0f); +} + void GameView::SetSaveButtonTooltips() { if (!Client::Ref().GetAuthUser().ID) diff --git a/src/gui/game/GameView.h b/src/gui/game/GameView.h index b616fd23f..c5ec9de0a 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -126,6 +126,7 @@ private: void enableAltBehaviour(); void disableAltBehaviour(); void UpdateDrawMode(); + void UpdateToolStrength(); public: GameView(); virtual ~GameView();