mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-03 14:49:04 +00:00
feat: creating and duplicating profiles changes all the paths based on the uuid
This commit is contained in:
parent
bd8ecb645c
commit
ec404dce95
1 changed files with 59 additions and 16 deletions
|
@ -236,26 +236,45 @@ impl Display for Profile {
|
||||||
|
|
||||||
impl Default for Profile {
|
impl Default for Profile {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
let uuid = Uuid::new_v4().to_string();
|
||||||
|
let profile_dir = format!("{}/{}", get_data_dir(), uuid);
|
||||||
Self {
|
Self {
|
||||||
uuid: Uuid::new_v4().to_string(),
|
|
||||||
name: "Default profile name".into(),
|
name: "Default profile name".into(),
|
||||||
xrservice_path: data_monado_path(),
|
xrservice_path: format!("{}/xrservice", profile_dir),
|
||||||
xrservice_type: XRServiceType::Monado,
|
xrservice_type: XRServiceType::Monado,
|
||||||
xrservice_repo: None,
|
xrservice_repo: None,
|
||||||
xrservice_cmake_flags: HashMap::<String, String>::default(),
|
xrservice_cmake_flags: HashMap::<String, String>::default(),
|
||||||
opencomposite_path: data_opencomposite_path(),
|
features: ProfileFeatures {
|
||||||
features: ProfileFeatures::default(),
|
libsurvive: ProfileFeature {
|
||||||
|
enabled: false,
|
||||||
|
path: Some(format!("{}/libsurvive", profile_dir)),
|
||||||
|
repo: None,
|
||||||
|
feature_type: ProfileFeatureType::Libsurvive,
|
||||||
|
},
|
||||||
|
basalt: ProfileFeature {
|
||||||
|
enabled: false,
|
||||||
|
path: Some(format!("{}/basalt", profile_dir)),
|
||||||
|
repo: None,
|
||||||
|
feature_type: ProfileFeatureType::Basalt,
|
||||||
|
},
|
||||||
|
openhmd: ProfileFeature {
|
||||||
|
enabled: false,
|
||||||
|
path: Some(format!("{}/openhmd", profile_dir)),
|
||||||
|
repo: None,
|
||||||
|
feature_type: ProfileFeatureType::OpenHmd,
|
||||||
|
},
|
||||||
|
mercury_enabled: false,
|
||||||
|
},
|
||||||
environment: HashMap::new(),
|
environment: HashMap::new(),
|
||||||
prefix: format!(
|
prefix: format!("{}/prefixes/{}", get_data_dir(), uuid),
|
||||||
"{data}/prefixes/default_profile_prefix",
|
|
||||||
data = get_data_dir()
|
|
||||||
),
|
|
||||||
can_be_built: true,
|
can_be_built: true,
|
||||||
pull_on_build: true,
|
pull_on_build: true,
|
||||||
opencomposite_repo: None,
|
opencomposite_repo: None,
|
||||||
|
opencomposite_path: format!("{}/opencomposite", profile_dir),
|
||||||
editable: true,
|
editable: true,
|
||||||
lighthouse_driver: LighthouseDriver::default(),
|
lighthouse_driver: LighthouseDriver::default(),
|
||||||
xrservice_launch_options: String::default(),
|
xrservice_launch_options: String::default(),
|
||||||
|
uuid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,10 +326,30 @@ impl Profile {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_duplicate(&self) -> Self {
|
pub fn create_duplicate(&self) -> Self {
|
||||||
let mut dup = self.clone();
|
if !self.can_be_built {
|
||||||
dup.uuid = Uuid::new_v4().to_string();
|
let mut dup = self.clone();
|
||||||
dup.editable = true;
|
dup.uuid = Uuid::new_v4().to_string();
|
||||||
dup.name = format!("Duplicate of {}", dup.name);
|
dup.name = format!("Duplicate of {}", dup.name);
|
||||||
|
dup.editable = true;
|
||||||
|
return dup;
|
||||||
|
}
|
||||||
|
let mut dup = Self::default();
|
||||||
|
dup.name = format!("Duplicate of {}", self.name);
|
||||||
|
dup.xrservice_type = self.xrservice_type.clone();
|
||||||
|
dup.xrservice_repo = self.xrservice_repo.clone();
|
||||||
|
dup.xrservice_cmake_flags = self.xrservice_cmake_flags.clone();
|
||||||
|
dup.features.libsurvive.enabled = self.features.libsurvive.enabled;
|
||||||
|
dup.features.libsurvive.repo = self.features.libsurvive.repo.clone();
|
||||||
|
dup.features.basalt.enabled = self.features.basalt.enabled;
|
||||||
|
dup.features.basalt.repo = self.features.basalt.repo.clone();
|
||||||
|
dup.features.openhmd.enabled = self.features.openhmd.enabled;
|
||||||
|
dup.features.openhmd.repo = self.features.openhmd.repo.clone();
|
||||||
|
dup.features.mercury_enabled = self.features.mercury_enabled;
|
||||||
|
dup.environment = self.environment.clone();
|
||||||
|
dup.pull_on_build = self.pull_on_build;
|
||||||
|
dup.opencomposite_repo = self.opencomposite_repo.clone();
|
||||||
|
dup.lighthouse_driver = self.lighthouse_driver;
|
||||||
|
dup.xrservice_launch_options = self.xrservice_launch_options.clone();
|
||||||
dup
|
dup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,10 +386,14 @@ impl Profile {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn xrservice_binary(&self) -> String {
|
pub fn xrservice_binary(&self) -> String {
|
||||||
match self.xrservice_type {
|
format!(
|
||||||
XRServiceType::Monado => format!("{pfx}/bin/monado-service", pfx = self.prefix),
|
"{}/bin/{}",
|
||||||
XRServiceType::Wivrn => format!("{pfx}/bin/wivrn-server", pfx = self.prefix),
|
self.prefix,
|
||||||
}
|
match self.xrservice_type {
|
||||||
|
XRServiceType::Monado => "monado-service",
|
||||||
|
XRServiceType::Wivrn => "wivrn-server",
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn can_start(&self) -> bool {
|
pub fn can_start(&self) -> bool {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue