Skip to content

Commit

Permalink
[Config] Tweaked mouse sensivity and added menu option for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Jan 26, 2020
1 parent 4e9f650 commit 8922f53
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/source/states/GameState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ GameState::GameState(const std::string &host, int port) {
void GameState::onEvent(const SDL_Event &event) {
if (event.type == SDL_MOUSEMOTION) {
if(SCREEN_WIDTH / 2 != event.motion.x || SCREEN_HEIGHT / 2 != event.motion.y) {
m_player.turnH(event.motion.xrel * 0.06);
m_player.turnV(-event.motion.yrel * 0.06);
m_player.turnH(event.motion.xrel * 0.01 * Config::mouseSensitivity);
m_player.turnV(-event.motion.yrel * 0.01 * Config::mouseSensitivity);

gk::Mouse::resetToWindowCenter();
}
Expand Down
5 changes: 5 additions & 0 deletions client/source/states/SettingsMenuState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ void SettingsMenuState::addInputButtons() {
m_currentKeyButton = &button;
});
}

m_menuWidget.addButton("Mouse sensitivity: " + std::to_string(Config::mouseSensitivity), [] (TextButton &button) {
Config::mouseSensitivity = std::max(2, (Config::mouseSensitivity + 2) % 14);
button.setText("Mouse sensitivity: " + std::to_string(Config::mouseSensitivity));
});
}

TextButton &SettingsMenuState::addToggleButton(const std::string &text, bool &configOption, bool worldReloadRequested) {
Expand Down
1 change: 1 addition & 0 deletions common/include/core/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace Config {
extern bool isWireframeModeEnabled;
extern u16 renderDistance;
extern float cameraFOV;
extern u8 mouseSensitivity;
}

#endif // CONFIG_HPP_
1 change: 1 addition & 0 deletions common/source/core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ bool Config::isAmbientOcclusionEnabled = false;
bool Config::isWireframeModeEnabled = false;
u16 Config::renderDistance = 8;
float Config::cameraFOV = 70.0f;
u8 Config::mouseSensitivity = 8;

0 comments on commit 8922f53

Please sign in to comment.