refactor: update everything to latest fusion and to rust edition 2024 (#7)

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit was merged in pull request #7.
This commit is contained in:
Schmarni
2025-04-07 22:59:41 +02:00
committed by GitHub
parent e28a8e8e1e
commit f5008ff5b5
14 changed files with 255 additions and 185 deletions

View File

@@ -4,7 +4,7 @@ use clap::Parser;
use color_eyre::{eyre::Result, Report};
use manifest_dir_macros::directory_relative_path;
use protostar::xdg::parse_desktop_file;
use stardust_xr_fusion::{client::Client, node::NodeType, root::RootAspect};
use stardust_xr_fusion::{client::Client, root::RootAspect};
use std::path::PathBuf;
use tracing_subscriber::EnvFilter;
@@ -25,20 +25,38 @@ async fn main() -> Result<()> {
.init();
color_eyre::install()?;
let args = Args::parse();
let (client, event_loop) = Client::connect_with_async_loop().await?;
client.set_base_prefixes(&[directory_relative_path!("../res")])?;
let owned_client = Client::connect().await?;
let client = owned_client.handle();
let async_loop = owned_client.async_event_loop();
client
.get_root()
.set_base_prefixes(&[directory_relative_path!("../res").to_string()])?;
let protostar = Single::create_from_desktop_file(
let mut protostar = Single::create_from_desktop_file(
client.get_root(),
[0.0, 0.0, 0.0],
parse_desktop_file(args.desktop_file).map_err(Report::msg)?,
)?;
let _root = client.get_root().alias().wrap(protostar)?;
let mut owned_client = async_loop.stop().await.unwrap();
let event_loop = owned_client.sync_event_loop(|handle, _| {
let Some(event) = handle.get_root().recv_root_event() else {
return;
};
match event {
stardust_xr_fusion::root::RootEvent::Ping { response } => response.send(Ok(())),
stardust_xr_fusion::root::RootEvent::Frame { info } => {
protostar.frame(info);
}
stardust_xr_fusion::root::RootEvent::SaveState { response } => {
response.send(protostar.save_state());
}
}
});
tokio::select! {
_ = tokio::signal::ctrl_c() => (),
e = event_loop => e??,
e = event_loop => e?,
};
Ok(())
}

View File

@@ -12,10 +12,10 @@ use stardust_xr_fusion::{
},
fields::{Field, Shape},
node::NodeType,
root::{ClientState, FrameInfo, RootHandler},
root::{ClientState, FrameInfo},
spatial::{Spatial, SpatialAspect, SpatialRefAspect, Transform},
};
use stardust_xr_molecules::{Grabbable, GrabbableSettings};
use stardust_xr_molecules::{FrameSensitive, Grabbable, GrabbableSettings, UIElement};
use std::f32::consts::PI;
use tween::{QuartInOut, Tweener};
@@ -146,9 +146,11 @@ impl Single {
self.grabbable.content_parent()
}
}
impl RootHandler for Single {
fn frame(&mut self, info: FrameInfo) {
let _ = self.grabbable.update(&info);
impl Single {
pub fn frame(&mut self, info: FrameInfo) {
if self.grabbable.handle_events() {
self.grabbable.frame(&info);
}
if let Some(grabbable_move) = &mut self.grabbable_move {
if !grabbable_move.is_finished() {
@@ -224,8 +226,8 @@ impl RootHandler for Single {
self.grabbable_shrink = Some(Tweener::quart_in_out(MODEL_SCALE, 0.0001, 0.25));
let application = self.application.clone();
let space = self.content_parent().alias();
let root = self.root.alias();
let space = self.content_parent().clone();
let root = self.root.clone();
//TODO: split the executable string for the args
tokio::task::spawn(async move {
@@ -244,7 +246,7 @@ impl RootHandler for Single {
}
}
fn save_state(&mut self) -> color_eyre::eyre::Result<ClientState> {
pub fn save_state(&mut self) -> color_eyre::eyre::Result<ClientState> {
ClientState::from_root(self.content_parent())
}
}