skybox selector

This commit is contained in:
galister 2026-04-22 19:09:26 +09:00
parent 16446f7808
commit 9986b71b26
9 changed files with 66 additions and 25 deletions

View File

@ -29,7 +29,7 @@
</div>
<div gap="8" flex_direction="column" width="100%">
<label text="Curve"/>
<label text="Curve (0 = disabled)"/>
<Slider id="slider_keying_curve" min_value="0" max_value="100" macro="slider"/>
</div>
</div>

View File

@ -27,12 +27,20 @@ impl<T> Tab<T> for TabGames<T> {
TabType::Games
}
fn update(&mut self, frontend: &mut Frontend<T>, time_ms: u32, _data: &mut T) -> anyhow::Result<()> {
fn update(&mut self, frontend: &mut Frontend<T>, time_ms: u32, data: &mut T) -> anyhow::Result<()> {
let mut config_change_kind = None;
self.view_game_list.update(&mut ViewUpdateParams {
layout: &mut frontend.layout,
executor: &mut frontend.executor,
executor: &frontend.executor,
general_config: frontend.interface.general_config(data),
config_change_kind: &mut config_change_kind,
})?;
if let Some(kind) = config_change_kind {
frontend.interface.config_changed(data, kind);
}
self.view_running_games_list.update(&mut frontend.layout, time_ms)?;
Ok(())
}

View File

@ -175,7 +175,9 @@ impl<T> Tab<T> for TabMonado<T> {
Task::GeneralSettingsChromaUpdate => {
if let Subtab::GeneralSettings(tab) = &mut self.subtab {
tab.chroma_update(frontend.interface.general_config(data));
frontend.interface.config_changed(data, ConfigChangeKind::EnvironmentBlend);
frontend
.interface
.config_changed(data, ConfigChangeKind::EnvironmentBlend);
}
}
Task::SetBrightness(brightness) => self.set_brightness(frontend, data, brightness),

View File

@ -19,7 +19,11 @@ use wgui::{
},
windowing::context_menu::{self, Blueprint, ContextMenu, TickResult},
};
use wlx_common::{config::GeneralConfig, config_io::ConfigRoot, dash_interface::{ConfigChangeKind, RecenterMode}};
use wlx_common::{
config::GeneralConfig,
config_io::ConfigRoot,
dash_interface::{ConfigChangeKind, RecenterMode},
};
use crate::{
frontend::{Frontend, FrontendTask, FrontendTasks},
@ -110,13 +114,21 @@ impl<T> Tab<T> for TabSettings<T> {
fn update(&mut self, frontend: &mut Frontend<T>, _time_ms: u32, data: &mut T) -> anyhow::Result<()> {
if let Some(tab) = &mut self.current_tab {
let mut config_change_kind = None;
tab.update(&mut ViewUpdateParams {
layout: &mut frontend.layout,
executor: &frontend.executor,
general_config: frontend.interface.general_config(data),
config_change_kind: &mut config_change_kind,
})?;
if let Some(kind) = config_change_kind {
frontend.interface.config_changed(data, kind);
}
}
let mut changed = false;
let mut changed = None;
for task in self.tasks.drain() {
match task {
Task::SetTab(tab) => {
@ -129,7 +141,7 @@ impl<T> Tab<T> for TabSettings<T> {
}
let config = frontend.interface.general_config(data);
*setting.mut_bool(config) = n;
changed = true;
changed = Some(setting.change_kind());
}
Task::UpdateFloat(setting, n) => {
self.tasks.push(Task::SettingUpdated(setting));
@ -138,7 +150,7 @@ impl<T> Tab<T> for TabSettings<T> {
}
let config = frontend.interface.general_config(data);
*setting.mut_f32(config) = n;
changed = true;
changed = Some(setting.change_kind());
}
Task::UpdateInt(setting, n) => {
self.tasks.push(Task::SettingUpdated(setting));
@ -147,7 +159,7 @@ impl<T> Tab<T> for TabSettings<T> {
}
let config = frontend.interface.general_config(data);
*setting.mut_i32(config) = n;
changed = true;
changed = Some(setting.change_kind());
}
Task::ClearPipewireTokens => {
let _ = std::fs::remove_file(ConfigRoot::Generic.get_conf_d_path().join("pw_tokens.yaml"))
@ -186,7 +198,7 @@ impl<T> Tab<T> for TabSettings<T> {
let config = frontend.interface.general_config(data);
config.autostart_apps.remove(idx);
frontend.layout.remove_widget(widget);
changed = true;
changed = Some(ConfigChangeKind::OverlayConfig);
}
}
Task::SettingUpdated(setting) => match setting {
@ -219,12 +231,12 @@ impl<T> Tab<T> for TabSettings<T> {
let setting = SettingType::from_str(setting).expect("Invalid Enum string");
let config = frontend.interface.general_config(data);
setting.set_enum(config, value);
changed = true;
changed = Some(ConfigChangeKind::OverlayConfig);
}
// Notify overlays of the change
if changed {
frontend.interface.config_changed(data, ConfigChangeKind::OverlayConfig);
if let Some(changed) = changed {
frontend.interface.config_changed(data, changed);
}
Ok(())
@ -277,6 +289,13 @@ enum SettingType {
}
impl SettingType {
pub fn change_kind(self) -> ConfigChangeKind {
match self {
Self::UseSkybox | Self::UsePassthrough => ConfigChangeKind::EnvironmentBlend,
_ => ConfigChangeKind::OverlayConfig,
}
}
pub fn mut_bool(self, config: &mut GeneralConfig) -> &mut bool {
match self {
Self::InvertScrollDirectionX => &mut config.invert_scroll_direction_x,

View File

@ -1,6 +1,6 @@
use crate::tab::settings::{
macros::{options_category, options_checkbox, options_slider_f32},
SettingType, SettingsMountParams, SettingsTab,
macros::{options_category, options_checkbox, options_slider_f32},
};
pub struct State {}

View File

@ -1,4 +1,4 @@
use wlx_common::async_executor::AsyncExecutor;
use wlx_common::{async_executor::AsyncExecutor, config::GeneralConfig, dash_interface::ConfigChangeKind};
pub mod app_launcher;
pub mod audio_settings;
@ -16,6 +16,8 @@ pub mod skymap_list_cell;
pub struct ViewUpdateParams<'a> {
pub layout: &'a mut wgui::layout::Layout,
pub executor: &'a AsyncExecutor,
pub general_config: &'a mut GeneralConfig,
pub config_change_kind: &'a mut Option<ConfigChangeKind>,
}
pub trait ViewTrait {

View File

@ -9,7 +9,7 @@ use wgui::{
renderer_vk::text::custom_glyph::CustomGlyphData,
task::Tasks,
};
use wlx_common::{async_executor::AsyncExecutor, config_io};
use wlx_common::{async_executor::AsyncExecutor, config::GeneralConfig, config_io, dash_interface::ConfigChangeKind};
use crate::{
frontend::{FrontendTask, FrontendTasks},
@ -75,7 +75,7 @@ impl ViewTrait for View {
self.show_skymap_resolution_selector(entry);
}
Task::SetSkymap(entry, resolution) => {
self.set_skymap(entry, resolution)?;
self.set_skymap(entry, resolution, par.general_config, par.config_change_kind)?;
}
}
}
@ -132,16 +132,23 @@ impl View {
Ok(())
}
fn set_skymap(&mut self, entry: SkymapCatalogEntry, resolution: SkymapResolution) -> anyhow::Result<()> {
fn set_skymap(
&mut self,
entry: SkymapCatalogEntry,
resolution: SkymapResolution,
config: &mut GeneralConfig,
change_kind: &mut Option<ConfigChangeKind>,
) -> anyhow::Result<()> {
let skymap_file_path = entry
.get_destination_path(resolution)
.context("Skymap not found" /* you shouldn't really see this, like ever. */)?;
log::error!(
"not implemented (skymap path to be loaded: {} with resolution {:?})",
skymap_file_path.to_string_lossy(),
resolution
);
config.skybox_texture = config_io::get_skymaps_root()
.join(skymap_file_path)
.to_str()
.context("Skymap filename not valid UTF-8")?
.into();
*change_kind = Some(ConfigChangeKind::EnvironmentBlend);
Ok(())
}

View File

@ -214,6 +214,7 @@ pub(super) fn posef_to_transform(pose: &xr::Posef) -> Affine3A {
pub(super) fn try_apply_chroma_key(app: &AppState) -> bool {
let Some(monado) = app.monado_state.as_ref() else {
log::warn!("Could not set Chroma Key: no monado_state");
return false;
};
@ -230,6 +231,5 @@ pub(super) fn try_apply_chroma_key(app: &AppState) -> bool {
return false;
}
// if all values were non-0, assume we're in chroma key mode
params.hsv_max[0] * params.hsv_max[1] * params.hsv_max[2] * params.curve > 0.001
params.curve > 0.001
}

View File

@ -569,6 +569,9 @@ fn reconfigure_environment_blend(
log::debug!("Allocating skybox.");
*skybox = create_skybox(xr_state, app);
}
} else {
log::debug!("Allocating skybox.");
*skybox = create_skybox(xr_state, app);
}
} else {
log::debug!("Destroying skybox.");