feat(settings): add player voice volume and voice input type options

- Add player voice volume slider and voice input type combo in settings UI.
- Add localization strings for player voice and voice input types.
- Add config overloads for const char* default values.
- Implement voice input types (PTT, always, off) in world scene.
- Refactor WorldScene member order and add load_config method.
- Update audio engine to use player voice volume.
- Downgrade some logging to debug.
This commit is contained in:
2026-07-20 17:47:05 +08:00
parent 4f2f439d83
commit e5bd7aa4d1
13 changed files with 100 additions and 25 deletions

View File

@@ -115,7 +115,7 @@ bool WorldScene::handle_event(const Event& e) {
}
void WorldScene::on_enter() {
auto& param = m_scene_manager.world_scene_param();
load_config();
m_error_ui.init();
if (param.host_game) {
@@ -163,6 +163,7 @@ void WorldScene::on_re_enter() {
m_error_ui.on_re_enter();
m_pasue_menu.on_re_enter();
m_client_world.reload_config();
load_config();
auto width = m_scene_manager.app().renderer().window_width();
auto height = m_scene_manager.app().renderer().window_height();
@@ -170,6 +171,20 @@ void WorldScene::on_re_enter() {
WindowResizeEvent{static_cast<int>(width), static_cast<int>(height)});
}
void WorldScene::load_config() {
auto type = m_scene_manager.app().config().get("voice_input", "PTT");
if (type == "off") {
m_input_type = VoiceInputType::OFF;
m_client_world.get_audio().audio_recording().stop();
} else if (type == "PTT") {
m_input_type = VoiceInputType::PTT;
m_client_world.get_audio().audio_recording().stop();
} else if (type == "always") {
m_input_type = VoiceInputType::ALWAYS;
m_client_world.get_audio().audio_recording().start();
}
}
bool WorldScene::handle_mouse_move_event(const MouseMoveEvent& e) {
if (m_chatting) {
return true;
@@ -291,14 +306,16 @@ bool WorldScene::handle_key_event(const KeyEvent& e) {
}
if (e.key == Key::V) {
auto& recording = m_client_world.get_audio().audio_recording();
if (e.action == KeyAction::PRESS) {
recording.start();
return true;
}
if (e.action == KeyAction::RELEASE) {
recording.stop();
return true;
if (m_input_type == VoiceInputType::PTT) {
auto& recording = m_client_world.get_audio().audio_recording();
if (e.action == KeyAction::PRESS) {
recording.start();
return true;
}
if (e.action == KeyAction::RELEASE) {
recording.stop();
return true;
}
}
}