From fde1211cd9ba6dcc44bfa8e11acf2b2741e9f392 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 5 Oct 2023 21:34:01 -0400 Subject: [PATCH] Add ctrl+e shortcut to cycle through edge modes --- README.md | 1 + src/gui/game/GameController.cpp | 26 ++++++++++++++++++++++++++ src/gui/game/GameController.h | 2 ++ src/gui/game/GameView.cpp | 5 ++++- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index af48ad012..925cc2e95 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ Controls | I | Invert Pressure and Velocity map | | W | Cycle gravity modes (use with Ctrl when STK2 is out) | | Y | Cycle air modes | +| Ctrl + E | Cycle edge modes | | B | Enter decoration editor menu | | Ctrl + B | Toggle decorations on/off | | N | Toggle Newtonian Gravity on/off | diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 751168ce6..283f99567 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -1012,6 +1012,32 @@ int GameController::GetTemperatureScale() return gameModel->GetTemperatureScale(); } +int GameController::GetEdgeMode() +{ + return gameModel->GetEdgeMode(); +} + +void GameController::SetEdgeMode(int edgeMode) +{ + if (edgeMode < 0 || edgeMode >= NUM_EDGE_MODES) + edgeMode = 0; + + gameModel->SetEdgeMode(edgeMode); + + switch (edgeMode) + { + case EDGE_VOID: + gameModel->SetInfoTip("Edge Mode: Void"); + break; + case EDGE_SOLID: + gameModel->SetInfoTip("Edge Mode: Solid"); + break; + case EDGE_LOOP: + gameModel->SetInfoTip("Edge Mode: Loop"); + break; + } +} + void GameController::SetActiveColourPreset(int preset) { gameModel->SetActiveColourPreset(preset); diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h index 6a1ebeca6..cb64d7a61 100644 --- a/src/gui/game/GameController.h +++ b/src/gui/game/GameController.h @@ -116,6 +116,8 @@ public: bool GetDebugHUD(); void SetTemperatureScale(int temperatureScale); int GetTemperatureScale(); + int GetEdgeMode(); + void SetEdgeMode(int edgeMode); void SetDebugFlags(unsigned int flags) { debugFlags = flags; } void SetActiveMenu(int menuID); std::vector GetMenuList(); diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index a25978cf4..8597c5397 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -1427,7 +1427,10 @@ void GameView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, c->ReloadSim(); break; case SDL_SCANCODE_E: - c->OpenElementSearch(); + if (ctrl) + c->SetEdgeMode(c->GetEdgeMode() + 1); + else + c->OpenElementSearch(); break; case SDL_SCANCODE_F: if (ctrl)