Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back UI tabs for settings #2076

Merged
merged 3 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion alvr/client_core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ fn connection_pipeline(
*ctx.control_sender.lock() = Some(control_sender);
*ctx.tracking_sender.lock() = Some(tracking_sender);
*ctx.statistics_sender.lock() = Some(statistics_sender);
if let Switch::Enabled(filter_level) = settings.logging.client_log_report_level {
if let Switch::Enabled(filter_level) = settings.extra.logging.client_log_report_level {
*LOG_CHANNEL_SENDER.lock() = Some(LogMirrorData {
sender: log_channel_sender,
filter_level,
Expand Down
2 changes: 1 addition & 1 deletion alvr/dashboard/src/dashboard/components/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl LogsTab {
}

pub fn update_settings(&mut self, settings: &Settings) {
self.raw_events_config = settings.logging.show_raw_events.clone();
self.raw_events_config = settings.extra.logging.show_raw_events.clone();
}

pub fn push_event(&mut self, event: Event) {
Expand Down
4 changes: 2 additions & 2 deletions alvr/dashboard/src/dashboard/components/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ impl NotificationBar {
}

pub fn update_settings(&mut self, settings: &Settings) {
self.min_notification_level = settings.logging.notification_level;
self.min_notification_level = settings.extra.logging.notification_level;

if settings.logging.show_notification_tip {
if settings.extra.logging.show_notification_tip {
if self.tip_message.is_none() {
self.tip_message = NOTIFICATION_TIPS
.choose(&mut rand::thread_rng())
Expand Down
171 changes: 91 additions & 80 deletions alvr/dashboard/src/dashboard/components/settings.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use super::{
notice,
presets::{builtin_schema, PresetControl},
NestingInfo, SettingControl, INDENTATION_STEP,
};
use crate::dashboard::{DisplayString, ServerRequest};
use alvr_gui_common::theme;
use alvr_packets::AudioDevicesList;
use alvr_session::{SessionSettings, Settings};
use eframe::egui::{Grid, Label, RichText, ScrollArea, Ui};
use serde_json as json;

use eframe::egui::{self, Align, Frame, Grid, Layout, RichText, ScrollArea, Ui};
#[cfg(target_arch = "wasm32")]
use instant::Instant;
use serde_json as json;
use settings_schema::SchemaNode;
use std::time::Duration;
#[cfg(not(target_arch = "wasm32"))]
Expand All @@ -24,6 +23,7 @@ struct TopLevelEntry {
}

pub struct SettingsTab {
selected_top_tab_id: String,
resolution_preset: PresetControl,
framerate_preset: PresetControl,
encoder_preset: PresetControl,
Expand Down Expand Up @@ -65,6 +65,7 @@ impl SettingsTab {
.collect();

Self {
selected_top_tab_id: "presets".to_string(),
resolution_preset: PresetControl::new(builtin_schema::resolution_schema()),
framerate_preset: PresetControl::new(builtin_schema::framerate_schema()),
encoder_preset: PresetControl::new(builtin_schema::encoder_preset_schema()),
Expand Down Expand Up @@ -129,90 +130,100 @@ impl SettingsTab {
}

let mut path_value_pairs = vec![];

ScrollArea::new([false, true])
.id_source("settings_tab_scroll")
.show(ui, |ui| {
ui.add(Label::new(RichText::new("Presets").size(20.0)));
ScrollArea::new([true, false])
.id_source("presets_scroll")
.show(ui, |ui| {
Grid::new("presets_grid")
.striped(true)
.num_columns(2)
.show(ui, |ui| {
path_value_pairs.extend(self.resolution_preset.ui(ui));
ui.with_layout(Layout::left_to_right(Align::Min), |ui| {
Frame::group(ui.style())
.fill(theme::DARKER_BG)
.inner_margin(egui::vec2(15.0, 12.0))
.show(ui, |ui| {
ui.horizontal_wrapped(|ui| {
ui.selectable_value(
&mut self.selected_top_tab_id,
"presets".to_string(),
RichText::new("Presets").raised().size(15.0),
);
for entry in self.top_level_entries.iter_mut() {
ui.selectable_value(
&mut self.selected_top_tab_id,
entry.id.id.clone(),
RichText::new(entry.id.display.clone()).raised().size(15.0),
);
}
})
})
});

if self.selected_top_tab_id == "presets" {
ScrollArea::new([false, true])
.id_source("presets_scroll")
.show(ui, |ui| {
Grid::new("presets_grid")
.striped(true)
.num_columns(2)
.show(ui, |ui| {
ui.add_space(INDENTATION_STEP);
path_value_pairs.extend(self.resolution_preset.ui(ui));
ui.end_row();

ui.add_space(INDENTATION_STEP);
path_value_pairs.extend(self.framerate_preset.ui(ui));
ui.end_row();

ui.add_space(INDENTATION_STEP);
path_value_pairs.extend(self.encoder_preset.ui(ui));
ui.end_row();

if let Some(preset) = &mut self.game_audio_preset {
ui.add_space(INDENTATION_STEP);
path_value_pairs.extend(preset.ui(ui));
ui.end_row();
}

path_value_pairs.extend(self.framerate_preset.ui(ui));
if let Some(preset) = &mut self.microphone_preset {
ui.add_space(INDENTATION_STEP);
path_value_pairs.extend(preset.ui(ui));
ui.end_row();
}

path_value_pairs.extend(self.encoder_preset.ui(ui));
ui.end_row();

if let Some(preset) = &mut self.game_audio_preset {
path_value_pairs.extend(preset.ui(ui));
ui.end_row();
}

if let Some(preset) = &mut self.microphone_preset {
path_value_pairs.extend(preset.ui(ui));
ui.end_row();
ui.add_space(INDENTATION_STEP);
path_value_pairs.extend(self.eye_face_tracking_preset.ui(ui));
ui.end_row();
})
});
} else {
ScrollArea::new([false, true])
.id_source(format!("{}_scroll", self.selected_top_tab_id))
.show(ui, |ui| {
Grid::new(format!("{}_grid", self.selected_top_tab_id))
.striped(true)
.num_columns(2)
.show(ui, |ui| {
if let Some(session_fragment) = &mut self.session_settings_json {
let session_fragments_mut =
session_fragment.as_object_mut().unwrap();

let entry = self
.top_level_entries
.iter_mut()
.find(|entry: &&mut TopLevelEntry| {
entry.id.id == self.selected_top_tab_id
})
.unwrap();

let response = entry.control.ui(
ui,
&mut session_fragments_mut[&entry.id.id],
false,
);

if let Some(response) = response {
path_value_pairs.push(response);
}

path_value_pairs.extend(self.eye_face_tracking_preset.ui(ui));
ui.end_row();
})
});

ui.add_space(15.0);

ui.horizontal(|ui| {
ui.add(Label::new(
RichText::new("All Settings (Advanced)").size(20.0),
));
notice::notice(ui, "Changing some advanced settings may break ALVR");
}
})
});
ScrollArea::new([true, false])
.id_source("advanced_scroll")
.show(ui, |ui| {
Grid::new("advanced_grid")
.striped(true)
.num_columns(2)
.show(ui, |ui| {
if let Some(session_fragment) = &mut self.session_settings_json {
let session_fragments_mut =
session_fragment.as_object_mut().unwrap();

for entry in self.top_level_entries.iter_mut() {
ui.horizontal(|ui| {
ui.add_space(INDENTATION_STEP);
let label_res = ui.add(Label::new(
RichText::new(&entry.id.display)
.size(18.0)
.monospace(),
));
if cfg!(debug_assertions) {
label_res.on_hover_text(&*entry.id);
}
});

let response = entry.control.ui(
ui,
&mut session_fragments_mut[&entry.id.id],
true,
);

if let Some(response) = response {
path_value_pairs.push(response);
}

ui.end_row();
}
}
})
});
});
}

if !path_value_pairs.is_empty() {
requests.push(ServerRequest::SetValues(path_value_pairs));
Expand Down
5 changes: 3 additions & 2 deletions alvr/dashboard/src/dashboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl eframe::App for Dashboard {
self.logs_tab.update_settings(&settings);
self.notification_bar.update_settings(&settings);
if self.just_opened {
if settings.open_setup_wizard {
if settings.extra.open_setup_wizard {
self.setup_wizard_open = true;
}

Expand Down Expand Up @@ -210,7 +210,7 @@ impl eframe::App for Dashboard {
if finished {
requests.push(ServerRequest::SetValues(vec![PathValuePair {
path: alvr_packets::parse_path(
"session_settings.open_setup_wizard",
"session_settings.extra.open_setup_wizard",
),
value: serde_json::Value::Bool(false),
}]))
Expand Down Expand Up @@ -341,6 +341,7 @@ impl eframe::App for Dashboard {
.as_ref()
.map(|s| {
s.to_settings()
.extra
.steamvr_launcher
.open_close_steamvr_with_dashboard
})
Expand Down
4 changes: 3 additions & 1 deletion alvr/dashboard/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fn main() {
data_manager
.session_mut()
.session_settings
.extra
.patches
.linux_async_reprojection = false;
}
Expand All @@ -63,11 +64,12 @@ fn main() {
let mut session_ref = data_manager.session_mut();
session_ref.server_version = ALVR_VERSION.clone();
session_ref.client_connections.clear();
session_ref.session_settings.open_setup_wizard = true;
session_ref.session_settings.extra.open_setup_wizard = true;
}

if data_manager
.settings()
.extra
.steamvr_launcher
.open_close_steamvr_with_dashboard
{
Expand Down
6 changes: 5 additions & 1 deletion alvr/dashboard/src/steamvr_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ impl Launcher {

let mut data_source = data_sources::get_local_data_source();

let launch_action = &data_source.settings().steamvr_launcher.driver_launch_action;
let launch_action = &data_source
.settings()
.extra
.steamvr_launcher
.driver_launch_action;

if !matches!(launch_action, DriverLaunchAction::NoAction) {
let other_drivers_paths = if matches!(
Expand Down
20 changes: 13 additions & 7 deletions alvr/server/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ pub fn contruct_openvr_config(session: &SessionConfig) -> OpenvrConfig {
saturation,
gamma,
sharpening,
linux_async_compute: settings.patches.linux_async_compute,
linux_async_reprojection: settings.patches.linux_async_reprojection,
linux_async_compute: settings.extra.patches.linux_async_compute,
linux_async_reprojection: settings.extra.patches.linux_async_reprojection,
nvenc_tuning_preset: nvenc_overrides.tuning_preset as u32,
nvenc_multi_pass: nvenc_overrides.multi_pass as u32,
nvenc_adaptive_quantization_mode: nvenc_overrides.adaptive_quantization_mode as u32,
Expand All @@ -225,7 +225,7 @@ pub fn contruct_openvr_config(session: &SessionConfig) -> OpenvrConfig {
rc_max_bitrate: nvenc_overrides.rc_max_bitrate,
rc_average_bitrate: nvenc_overrides.rc_average_bitrate,
nvenc_enable_weighted_prediction: nvenc_overrides.enable_weighted_prediction,
capture_frame_dir: settings.capture.capture_frame_dir,
capture_frame_dir: settings.extra.capture.capture_frame_dir,
amd_bitrate_corruption_fix: settings.video.bitrate.image_corruption_fix,
_controller_profile,
..old_config
Expand Down Expand Up @@ -865,7 +865,7 @@ fn connection_pipeline(

{
let data_manager_lock = SERVER_DATA_MANAGER.read();
if data_manager_lock.settings().logging.log_tracking {
if data_manager_lock.settings().extra.logging.log_tracking {
alvr_events::send_event(EventType::Tracking(Box::new(TrackingEvent {
device_motions: motions
.iter()
Expand Down Expand Up @@ -1175,7 +1175,12 @@ fn connection_pipeline(
ClientControlPacket::Buttons(entries) => {
{
let data_manager_lock = SERVER_DATA_MANAGER.read();
if data_manager_lock.settings().logging.log_button_presses {
if data_manager_lock
.settings()
.extra
.logging
.log_button_presses
{
alvr_events::send_event(EventType::Buttons(
entries
.iter()
Expand Down Expand Up @@ -1321,7 +1326,7 @@ fn connection_pipeline(
}
}

if settings.capture.startup_video_recording {
if settings.extra.capture.startup_video_recording {
crate::create_recording_file(server_data_lock.settings());
}

Expand Down Expand Up @@ -1394,6 +1399,7 @@ pub extern "C" fn send_video(timestamp_ns: u64, buffer_ptr: *mut u8, len: i32, i
if let Switch::Enabled(config) = &SERVER_DATA_MANAGER
.read()
.settings()
.extra
.capture
.rolling_video_files
{
Expand Down Expand Up @@ -1468,7 +1474,7 @@ pub extern "C" fn send_haptics(device_id: u64, duration_s: f32, frequency: f32,
let haptics_config = {
let data_manager_lock = SERVER_DATA_MANAGER.read();

if data_manager_lock.settings().logging.log_haptics {
if data_manager_lock.settings().extra.logging.log_haptics {
alvr_events::send_event(EventType::Haptics(HapticsEvent {
path: DEVICE_ID_TO_PATH
.get(&haptics.device_id)
Expand Down
1 change: 1 addition & 0 deletions alvr/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ fn init() {
if SERVER_DATA_MANAGER
.read()
.settings()
.extra
.logging
.prefer_backtrace
{
Expand Down
8 changes: 7 additions & 1 deletion alvr/server/src/logging_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ pub fn init_logging(events_sender: Sender<Event>) {
log_dispatch = log_dispatch.level(LevelFilter::Info);
}

if SERVER_DATA_MANAGER.read().settings().logging.log_to_disk {
if SERVER_DATA_MANAGER
.read()
.settings()
.extra
.logging
.log_to_disk
{
log_dispatch = log_dispatch.chain(
fs::OpenOptions::new()
.write(true)
Expand Down
Loading
Loading