From e773abdcc89c1f7cc09cce39c6d4b30eaa6fd69e Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 20 Oct 2012 20:06:38 -0400 Subject: [PATCH] Ctrl + G gravity grid toggle --- src/game/GameController.cpp | 6 ++++++ src/game/GameController.h | 1 + src/game/GameModel.cpp | 14 ++++++++++++++ src/game/GameModel.h | 2 ++ src/game/GameView.cpp | 6 ++++-- src/game/QuickOptions.h | 4 ++-- 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index dfe3a9449..07ccfe909 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -860,6 +860,12 @@ void GameController::SetDecoration() gameModel->SetDecoration(!gameModel->GetDecoration()); } +void GameController::ShowGravityGrid() +{ + gameModel->ShowGravityGrid(!gameModel->GetGravityGrid()); + gameModel->UpdateQuickOptions(); +} + void GameController::SetActiveColourPreset(int preset) { gameModel->SetActiveColourPreset(preset); diff --git a/src/game/GameController.h b/src/game/GameController.h index 2ac8bea1c..4c7a8c984 100644 --- a/src/game/GameController.h +++ b/src/game/GameController.h @@ -94,6 +94,7 @@ public: void SetPaused(); void SetDecoration(bool decorationState); void SetDecoration(); + void ShowGravityGrid(); void SetActiveMenu(Menu * menu); void SetActiveTool(int toolSelection, Tool * tool); void SetActiveColourPreset(int preset); diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp index 0a3c57701..4a11d5520 100644 --- a/src/game/GameModel.cpp +++ b/src/game/GameModel.cpp @@ -802,6 +802,20 @@ bool GameModel::GetAHeatEnable() return sim->aheat_enable; } +void GameModel::ShowGravityGrid(bool showGrid) +{ + ren->gravityFieldEnabled = showGrid; + if (showGrid) + SetInfoTip("Gravity Grid: On"); + else + SetInfoTip("Gravity Grid: Off"); +} + +bool GameModel::GetGravityGrid() +{ + return ren->gravityFieldEnabled; +} + void GameModel::FrameStep(int frames) { sim->framerender += frames; diff --git a/src/game/GameModel.h b/src/game/GameModel.h index 7288c3266..c1d97d627 100644 --- a/src/game/GameModel.h +++ b/src/game/GameModel.h @@ -162,6 +162,8 @@ public: void SetDecoration(bool decorationState); bool GetAHeatEnable(); void SetAHeatEnable(bool aHeat); + bool GetGravityGrid(); + void ShowGravityGrid(bool showGrid); void ClearSimulation(); vector GetMenuList(); vector GetUnlistedTools(); diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 73b383301..0e3f58036 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -1271,7 +1271,9 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool c->FrameStep(); break; case 'g': - if(shift) + if (ctrl) + c->ShowGravityGrid(); + else if(shift) c->AdjustGridSize(-1); else c->AdjustGridSize(1); @@ -1419,7 +1421,7 @@ void GameView::OnBlur() void GameView::OnTick(float dt) { if(selectMode==PlaceSave && !placeSaveThumb) - selectMode = SelectNone; + selectMode = SelectNone; if(zoomEnabled && !zoomCursorFixed) c->SetZoomPosition(currentMouse); if(drawMode == DrawPoints) diff --git a/src/game/QuickOptions.h b/src/game/QuickOptions.h index 545505110..7c31f9c51 100644 --- a/src/game/QuickOptions.h +++ b/src/game/QuickOptions.h @@ -29,11 +29,11 @@ public: } virtual bool GetToggle() { - return m->GetRenderer()->gravityFieldEnabled; + return m->GetGravityGrid(); } virtual void perform() { - m->GetRenderer()->gravityFieldEnabled = !m->GetRenderer()->gravityFieldEnabled; + m->ShowGravityGrid(!m->GetGravityGrid()); } };