diff --git a/src/noggit/MapView.cpp b/src/noggit/MapView.cpp index 362dee2d..ea33965c 100644 --- a/src/noggit/MapView.cpp +++ b/src/noggit/MapView.cpp @@ -4303,13 +4303,14 @@ void MapView::keyPressEvent (QKeyEvent *event) if (event->key() == Qt::Key_Space) _mod_space_down = true; + checkInputsSettings(); // movement - if (event->key() == Qt::Key_W) + if (event->key() == _inputs[0]) { moving = 1.0f; } - if (event->key() == Qt::Key_S) + if (event->key() == _inputs[1]) { moving = -1.0f; } @@ -4332,20 +4333,20 @@ void MapView::keyPressEvent (QKeyEvent *event) turn = -0.75f; } - if (event->key() == Qt::Key_D) + if (event->key() == _inputs[2]) { strafing = 1.0f; } - if (event->key() == Qt::Key_A) + if (event->key() == _inputs[3]) { strafing = -1.0f; } - if (event->key() == Qt::Key_Q) + if (event->key() == _inputs[4]) { updown = 1.0f; } - if (event->key() == Qt::Key_E) + if (event->key() == _inputs[5]) { updown = -1.0f; } @@ -4459,8 +4460,10 @@ void MapView::keyReleaseEvent (QKeyEvent* event) if (event->key() == Qt::Key_Space) _mod_space_down = false; + checkInputsSettings(); + // movement - if (event->key() == Qt::Key_W || event->key() == Qt::Key_S) + if (event->key() == _inputs[0] || event->key() == _inputs[1]) { moving = 0.0f; } @@ -4475,12 +4478,12 @@ void MapView::keyReleaseEvent (QKeyEvent* event) turn = 0.0f; } - if (event->key() == Qt::Key_D || event->key() == Qt::Key_A) + if (event->key() == _inputs[2] || event->key() == _inputs[3]) { strafing = 0.0f; } - if (event->key() == Qt::Key_Q || event->key() == Qt::Key_E) + if (event->key() == _inputs[4] || event->key() == _inputs[5]) { updown = 0.0f; } @@ -4518,6 +4521,19 @@ void MapView::keyReleaseEvent (QKeyEvent* event) } +void MapView::checkInputsSettings() +{ + QString _locale = _settings->value("keyboard_locale", "QWERTY").toString(); + + // default is QWERTY + _inputs = std::array{Qt::Key_W, Qt::Key_S, Qt::Key_D, Qt::Key_A, Qt::Key_Q, Qt::Key_E}; + + if (_locale == "AZERTY") + { + _inputs = std::array{Qt::Key_Z, Qt::Key_S, Qt::Key_D, Qt::Key_Q, Qt::Key_A, Qt::Key_E}; + } +} + void MapView::focusOutEvent (QFocusEvent*) { _mod_alt_down = false; diff --git a/src/noggit/MapView.h b/src/noggit/MapView.h index f7d79322..9c125817 100644 --- a/src/noggit/MapView.h +++ b/src/noggit/MapView.h @@ -132,6 +132,9 @@ private: bool _camera_moved_since_last_draw = true; + std::array _inputs = {Qt::Key_W, Qt::Key_S, Qt::Key_D, Qt::Key_A, Qt::Key_Q, Qt::Key_E}; + void checkInputsSettings(); + public: Noggit::BoolToggleProperty _draw_contour = {false}; Noggit::BoolToggleProperty _draw_mfbo = {false}; diff --git a/src/noggit/ui/windows/settingsPanel/SettingsPanel.cpp b/src/noggit/ui/windows/settingsPanel/SettingsPanel.cpp index 17e46745..3cf2dcaf 100644 --- a/src/noggit/ui/windows/settingsPanel/SettingsPanel.cpp +++ b/src/noggit/ui/windows/settingsPanel/SettingsPanel.cpp @@ -225,6 +225,7 @@ namespace Noggit ui->_nativeMenubar->setChecked(_settings->value("nativeMenubar", true).toBool()); ui->_additional_file_loading_log->setChecked( _settings->value("additional_file_loading_log", false).toBool()); + ui->_keyboard_locale->setCurrentText(_settings->value("keyboard_locale", "QWERTY").toString()); ui->_theme->setCurrentText(_settings->value("theme", "Dark").toString()); ui->assetBrowserBgCol->setColor(_settings->value("assetBrowser/background_color", @@ -284,6 +285,7 @@ namespace Noggit _settings->setValue("unload_interval", ui->_adt_unload_check_interval->value()); _settings->setValue("uid_startup_check", ui->_uid_cb->isChecked()); _settings->setValue("additional_file_loading_log", ui->_additional_file_loading_log->isChecked()); + _settings->setValue("keyboard_locale", ui->_keyboard_locale->currentText()); _settings->setValue("systemWindowFrame", ui->_systemWindowFrame->isChecked()); _settings->setValue("nativeMenubar", ui->_nativeMenubar->isChecked()); @@ -313,4 +315,4 @@ namespace Noggit emit saved(); } } -} \ No newline at end of file +} diff --git a/src/noggit/ui/windows/settingsPanel/SettingsPanel.ui b/src/noggit/ui/windows/settingsPanel/SettingsPanel.ui index 1a9f9648..00ac46d9 100644 --- a/src/noggit/ui/windows/settingsPanel/SettingsPanel.ui +++ b/src/noggit/ui/windows/settingsPanel/SettingsPanel.ui @@ -6,8 +6,8 @@ 0 0 - 550 - 480 + 617 + 576 @@ -994,23 +994,44 @@ - + + + 10 + + + 10 + + + 0 + - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + 0 + + @@ -1023,7 +1044,7 @@ - + @@ -1033,37 +1054,7 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + @@ -1076,44 +1067,14 @@ - + - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + @@ -1126,44 +1087,14 @@ - + - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + @@ -1176,28 +1107,67 @@ - + - - - - Qt::Horizontal - - + + + - 40 - 20 + 134 + 0 - + + Keyboard locale + + + + + + + + 0 + 0 + + + + + 80 + 16777215 + + + + + QWERTY + + + + + AZERTY + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -2022,9 +1992,7 @@ 1 - - - +