fix terrible mouse bug from last commit, redo tool strengths to be less buggy and only ever have an effect on normal drawing (not lines / boxes)

This commit is contained in:
jacob1 2015-09-24 01:39:20 -04:00
parent e5ef3cd4a8
commit 5acf366d70
3 changed files with 25 additions and 26 deletions

View File

@ -422,7 +422,7 @@ void GameController::DrawRect(int toolSelection, ui::Point point1, ui::Point poi
Brush * cBrush = gameModel->GetBrush(); Brush * cBrush = gameModel->GetBrush();
if(!activeTool || !cBrush) if(!activeTool || !cBrush)
return; return;
activeTool->SetStrength(gameModel->GetToolStrength()); activeTool->SetStrength(1.0f);
activeTool->DrawRect(sim, cBrush, point1, point2); 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(); Brush * cBrush = gameModel->GetBrush();
if(!activeTool || !cBrush) if(!activeTool || !cBrush)
return; return;
activeTool->SetStrength(gameModel->GetToolStrength()); activeTool->SetStrength(1.0f);
activeTool->DrawLine(sim, cBrush, point1, point2); activeTool->DrawLine(sim, cBrush, point1, point2);
} }
@ -446,7 +446,7 @@ void GameController::DrawFill(int toolSelection, ui::Point point)
Brush * cBrush = gameModel->GetBrush(); Brush * cBrush = gameModel->GetBrush();
if(!activeTool || !cBrush) if(!activeTool || !cBrush)
return; return;
activeTool->SetStrength(gameModel->GetToolStrength()); activeTool->SetStrength(1.0f);
activeTool->DrawFill(sim, cBrush, point); activeTool->DrawFill(sim, cBrush, point);
} }

View File

@ -1101,9 +1101,9 @@ void GameView::OnMouseDown(int x, int y, unsigned button)
button = BUTTON_MIDDLE; button = BUTTON_MIDDLE;
if (!(zoomEnabled && !zoomCursorFixed)) if (!(zoomEnabled && !zoomCursorFixed))
{ {
isMouseDown = true;
if (selectMode != SelectNone) if (selectMode != SelectNone)
{ {
isMouseDown = true;
if (button == BUTTON_LEFT && selectPoint1.X == -1) if (button == BUTTON_LEFT && selectPoint1.X == -1)
{ {
selectPoint1 = c->PointTranslate(currentMouse); selectPoint1 = c->PointTranslate(currentMouse);
@ -1119,6 +1119,7 @@ void GameView::OnMouseDown(int x, int y, unsigned button)
toolIndex = 1; toolIndex = 1;
if (button == BUTTON_MIDDLE) if (button == BUTTON_MIDDLE)
toolIndex = 2; toolIndex = 2;
isMouseDown = true;
c->HistorySnapshot(); c->HistorySnapshot();
if (drawMode == DrawRect || drawMode == DrawLine) if (drawMode == DrawRect || drawMode == DrawLine)
{ {
@ -1890,33 +1891,29 @@ void GameView::NotifyPlaceSaveChanged(GameModel * sender)
void GameView::enableShiftBehaviour() void GameView::enableShiftBehaviour()
{ {
if(!shiftBehaviour) if (!shiftBehaviour)
{ {
shiftBehaviour = true; shiftBehaviour = true;
if (!isMouseDown || selectMode != SelectNone) if (!isMouseDown || selectMode != SelectNone)
UpdateDrawMode(); UpdateDrawMode();
else if (toolBrush && drawMode == DrawPoints) UpdateToolStrength();
c->SetToolStrength(10.0f);
} }
} }
void GameView::disableShiftBehaviour() void GameView::disableShiftBehaviour()
{ {
if(shiftBehaviour) if (shiftBehaviour)
{ {
shiftBehaviour = false; shiftBehaviour = false;
if (!isMouseDown || selectMode != SelectNone) if (!isMouseDown || selectMode != SelectNone)
UpdateDrawMode(); UpdateDrawMode();
if (!ctrlBehaviour) UpdateToolStrength();
c->SetToolStrength(1.0f);
else
c->SetToolStrength(.1f);
} }
} }
void GameView::enableAltBehaviour() void GameView::enableAltBehaviour()
{ {
if(!altBehaviour) if (!altBehaviour)
{ {
altBehaviour = true; altBehaviour = true;
drawSnap = true; drawSnap = true;
@ -1934,11 +1931,12 @@ void GameView::disableAltBehaviour()
void GameView::enableCtrlBehaviour() void GameView::enableCtrlBehaviour()
{ {
if(!ctrlBehaviour) if (!ctrlBehaviour)
{ {
ctrlBehaviour = true; ctrlBehaviour = true;
if (!isMouseDown || selectMode != SelectNone) if (!isMouseDown || selectMode != SelectNone)
UpdateDrawMode(); UpdateDrawMode();
UpdateToolStrength();
//Show HDD save & load buttons //Show HDD save & load buttons
saveSimulationButton->Appearance.BackgroundInactive = saveSimulationButton->Appearance.BackgroundHover = ui::Colour(255, 255, 255); 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."); searchButton->SetToolTip("Open a simulation from your hard drive.");
if (currentSaveType == 2) if (currentSaveType == 2)
((SplitButton*)saveSimulationButton)->SetShowSplit(true); ((SplitButton*)saveSimulationButton)->SetShowSplit(true);
if ((isMouseDown && selectMode == SelectNone) || (toolBrush && drawMode == DrawPoints))
{
if(!shiftBehaviour)
c->SetToolStrength(.1f);
else
c->SetToolStrength(10.0f);
}
} }
} }
void GameView::disableCtrlBehaviour() void GameView::disableCtrlBehaviour()
{ {
if(ctrlBehaviour) if (ctrlBehaviour)
{ {
ctrlBehaviour = false; ctrlBehaviour = false;
if (!isMouseDown || selectMode != SelectNone) if (!isMouseDown || selectMode != SelectNone)
UpdateDrawMode(); UpdateDrawMode();
UpdateToolStrength();
//Hide HDD save & load buttons //Hide HDD save & load buttons
saveSimulationButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0); 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."); searchButton->SetToolTip("Find & open a simulation. Hold Ctrl to load offline saves.");
if (currentSaveType == 2) if (currentSaveType == 2)
((SplitButton*)saveSimulationButton)->SetShowSplit(false); ((SplitButton*)saveSimulationButton)->SetShowSplit(false);
if(!shiftBehaviour)
c->SetToolStrength(1.0f);
else
c->SetToolStrength(10.0f);
} }
} }
@ -2007,6 +1995,16 @@ void GameView::UpdateDrawMode()
drawMode = DrawPoints; 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() void GameView::SetSaveButtonTooltips()
{ {
if (!Client::Ref().GetAuthUser().ID) if (!Client::Ref().GetAuthUser().ID)

View File

@ -126,6 +126,7 @@ private:
void enableAltBehaviour(); void enableAltBehaviour();
void disableAltBehaviour(); void disableAltBehaviour();
void UpdateDrawMode(); void UpdateDrawMode();
void UpdateToolStrength();
public: public:
GameView(); GameView();
virtual ~GameView(); virtual ~GameView();