Skip to content
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
67 changes: 47 additions & 20 deletions src/core/commands/command_load_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Command for LoadAssetsArgs {

let assets = get_required_assets(&assets, &project, &c);

info!("Loading assets: {:?}", assets);
info!("Assets to load: {:?}", assets);

let department = project
.departments
Expand All @@ -83,45 +83,74 @@ impl Command for LoadAssetsArgs {
};

for asset in assets.into_iter() {
info!("Loading asset: {}", asset);

info!("----");
info!("Loading Asset: `{}`", asset);
let elements = project.get_elements(asset.to_string(), &c);
info!("Resolved elements: {:#?}", elements);
for element in elements.iter() {
debug!("Resolved element: {:?}", element);
}

info!("Looking for files...");
for element in elements.iter() {
if element.1.is_shot_local() && self.common.shot.is_none() {
debug!(
"Element `{}` is shot local, but we are not in a shot context, skipping",
element.0
);
continue;
}

let files = VersionControl::get_element_files(
&project.version_control,
&project,
element.0.clone(),
element.1,
);

if files.is_empty() {
info!("`{}`: None", element.0)
}

for file in files.iter() {
info!("`{}`: ({}) {}", element.0, file.version, file.path);
let mut found_load_script = false;

for format in import_formats.iter() {
if file.path.ends_with(format) {
trace!("Getting script for format: {}", format);

let mut script_path = project.get_root_directory();
script_path.push("scripts");
script_path.push(self.program.clone());
script_path.push(scripts.get(format).unwrap().clone());

result.results.push(AssetLoadStep {
asset: asset.clone(),
element: element.0.clone(),
script: script_path.to_str().unwrap().to_string(),
file_type: format.clone(),
file: file.path.clone(),
version: file.version.clone(),
});

break;

match scripts.get(format) {
Some(script_file) => {
script_path.push(script_file.clone());

result.results.push(AssetLoadStep {
asset: asset.clone(),
element: element.0.clone(),
script: script_path.to_str().unwrap().to_string(),
file_type: format.clone(),
file: file.path.clone(),
version: file.version.clone(),
});

found_load_script = true;
break;
}
None => {}
}
}
}
}

info!("Checking import formats {:?}", import_formats)
if !found_load_script {
warn!("Found a file to load: {} but could not find any load script for the format in the department `{}`", file.path, self.common.department.clone().unwrap().to_string())
}
}
}

info!("----")
}

info!("Resuling load steps: {:#?}", result);
Expand All @@ -139,8 +168,6 @@ fn get_required_assets(
warn!("TODO: Check for dependency loops");
let mut result = Vec::new();
for asset in asset_names.into_iter() {
info!("Loading asset: {}", asset);

let elements = project.get_elements(asset.to_string(), context);
for (element, data) in elements.iter() {
match data.get_dependencies() {
Expand Down
8 changes: 4 additions & 4 deletions src/core/element/resolved_element_data.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[derive(Clone, Debug)]
pub struct ResolvedElementData {
scene_local: bool,
shot_local: bool,
dependencies: Option<Vec<String>>,
asset: Option<String>,
shot: Option<String>,
Expand All @@ -10,7 +10,7 @@ pub struct ResolvedElementData {
impl ResolvedElementData {
pub fn new() -> Self {
ResolvedElementData {
scene_local: false,
shot_local: false,
dependencies: None,
asset: None,
shot: None,
Expand All @@ -19,11 +19,11 @@ impl ResolvedElementData {
}

pub fn set_shot_local(&mut self, value: bool) {
self.scene_local = value;
self.shot_local = value;
}

pub fn is_shot_local(&self) -> bool {
self.scene_local
self.shot_local
}

pub fn set_shot(&mut self, value: &String) {
Expand Down
19 changes: 15 additions & 4 deletions src/core/version_control/common.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{collections::HashMap, path::PathBuf};

use log::{info, trace, warn};
use log::{trace, warn};
use serde::{Deserialize, Serialize};

use crate::core::{
Expand Down Expand Up @@ -70,9 +70,17 @@ pub fn resolve_element_path(
map.insert("element", element_name.clone());

if data.is_shot_local() {
map.insert("shot", data.get_shot().unwrap());
trace!("Resolved shot: {}", data.get_shot().unwrap())
match data.get_shot() {
Some(shot) => {
map.insert("shot", shot.clone());
trace!("Resolved shot: {}", shot)
},
None => {
return Err(ExportError::Message("Tried to resolve the path of a shot_local element, but we are not in a shot context".into()))
},
}
}

data
}
None => {
Expand Down Expand Up @@ -126,7 +134,10 @@ pub fn resolve_element_path(
}

let file_name = if element_data.is_shot_local() {
let shot_name = element_data.get_shot().unwrap().replace("/", "-");
let shot_name = element_data
.get_shot()
.expect("Element data is shot local, but the element data didn't resolve to a shot")
.replace("/", "-");
format!(
"{}_{}_{}_{}",
asset_name, shot_name, department, element_name
Expand Down
Loading