update last tool and drawMode when clicking too, fixes some issues

This commit is contained in:
jacob1
2015-10-10 01:17:19 -04:00
parent d4e3196070
commit 66863b7578
3 changed files with 11 additions and 0 deletions

View File

@@ -1061,6 +1061,11 @@ void GameController::SetActiveTool(int toolSelection, Tool * tool)
((PropertyTool *)tool)->OpenWindow(gameModel->GetSimulation()); ((PropertyTool *)tool)->OpenWindow(gameModel->GetSimulation());
} }
void GameController::SetLastTool(Tool * tool)
{
gameModel->SetLastTool(tool);
}
int GameController::GetReplaceModeFlags() int GameController::GetReplaceModeFlags()
{ {
return gameModel->GetSimulation()->replaceModeFlags; return gameModel->GetSimulation()->replaceModeFlags;

View File

@@ -105,6 +105,7 @@ public:
std::vector<Menu*> GetMenuList(); std::vector<Menu*> GetMenuList();
Tool * GetActiveTool(int selection); Tool * GetActiveTool(int selection);
void SetActiveTool(int toolSelection, Tool * tool); void SetActiveTool(int toolSelection, Tool * tool);
void SetLastTool(Tool * tool);
int GetReplaceModeFlags(); int GetReplaceModeFlags();
void SetReplaceModeFlags(int flags); void SetReplaceModeFlags(int flags);
void ActiveToolChanged(int toolSelection, Tool *tool); void ActiveToolChanged(int toolSelection, Tool *tool);

View File

@@ -1122,12 +1122,17 @@ void GameView::OnMouseDown(int x, int y, unsigned button)
} }
if (currentMouse.X >= 0 && currentMouse.X < XRES && currentMouse.Y >= 0 && currentMouse.Y < YRES) if (currentMouse.X >= 0 && currentMouse.X < XRES && currentMouse.Y >= 0 && currentMouse.Y < YRES)
{ {
// update tool index, set new "last" tool so GameView can detect certain tools properly
if (button == BUTTON_LEFT) if (button == BUTTON_LEFT)
toolIndex = 0; toolIndex = 0;
if (button == BUTTON_RIGHT) if (button == BUTTON_RIGHT)
toolIndex = 1; toolIndex = 1;
if (button == BUTTON_MIDDLE) if (button == BUTTON_MIDDLE)
toolIndex = 2; toolIndex = 2;
Tool *lastTool = c->GetActiveTool(toolIndex);
c->SetLastTool(lastTool);
UpdateDrawMode();
isMouseDown = true; isMouseDown = true;
c->HistorySnapshot(); c->HistorySnapshot();
if (drawMode == DrawRect || drawMode == DrawLine) if (drawMode == DrawRect || drawMode == DrawLine)