Skip to content

Commit

Permalink
fix terrible mouse bug from last commit, redo tool strengths to be le…
Browse files Browse the repository at this point in the history
…ss buggy and only ever have an effect on normal drawing (not lines / boxes)
  • Loading branch information
jacob1 committed Sep 24, 2015
1 parent e5ef3cd commit 5acf366
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/gui/game/GameController.cpp
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down
44 changes: 21 additions & 23 deletions src/gui/game/GameView.cpp
Expand Up @@ -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);
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
}
}

Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/gui/game/GameView.h
Expand Up @@ -126,6 +126,7 @@ class GameView: public ui::Window
void enableAltBehaviour();
void disableAltBehaviour();
void UpdateDrawMode();
void UpdateToolStrength();
public:
GameView();
virtual ~GameView();
Expand Down

0 comments on commit 5acf366

Please sign in to comment.