Permalink
Browse files

fix terrible mouse bug from last commit, redo tool strengths to be le…

…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 5acf366d7031e69aab3ff5d155d940166f4b8ef4
Showing with 25 additions and 26 deletions.
  1. +3 −3 src/gui/game/GameController.cpp
  2. +21 −23 src/gui/game/GameView.cpp
  3. +1 −0 src/gui/game/GameView.h
@@ -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);
}
@@ -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)
@@ -126,6 +126,7 @@ class GameView: public ui::Window
void enableAltBehaviour();
void disableAltBehaviour();
void UpdateDrawMode();
void UpdateToolStrength();
public:
GameView();
virtual ~GameView();

0 comments on commit 5acf366

Please sign in to comment.