-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(projects): use archives for project files to be able to include …
…media files etc
- Loading branch information
Showing
40 changed files
with
1,077 additions
and
682 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use crate::fixture::FixtureConfiguration; | ||
use crate::programmer::{Color, Position, Preset, Presets}; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] | ||
pub struct FixtureConfig { | ||
pub id: u32, | ||
pub name: String, | ||
pub fixture: String, | ||
pub channel: u16, | ||
pub universe: Option<u16>, | ||
#[serde(default)] | ||
pub mode: Option<String>, | ||
#[serde(default)] | ||
pub configuration: FixtureConfiguration, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq)] | ||
pub struct PresetsStore { | ||
#[serde(default)] | ||
pub intensity: Vec<Preset<f64>>, | ||
#[serde(default)] | ||
pub shutter: Vec<Preset<f64>>, | ||
#[serde(default)] | ||
pub color: Vec<Preset<Color>>, | ||
#[serde(default)] | ||
pub position: Vec<Preset<Position>>, | ||
} | ||
|
||
impl PresetsStore { | ||
pub fn load(&self, presets: &Presets) { | ||
for preset in self.intensity.iter() { | ||
presets.intensity.insert(preset.id, preset.clone()); | ||
} | ||
for preset in self.shutter.iter() { | ||
presets.shutter.insert(preset.id, preset.clone()); | ||
} | ||
for preset in self.color.iter() { | ||
presets.color.insert(preset.id, preset.clone()); | ||
} | ||
for preset in self.position.iter() { | ||
presets.position.insert(preset.id, preset.clone()); | ||
} | ||
} | ||
|
||
pub fn store(presets: &Presets) -> Self { | ||
let intensity = presets | ||
.intensity | ||
.iter() | ||
.map(|entry| entry.value().clone()) | ||
.collect(); | ||
let shutter = presets | ||
.shutter | ||
.iter() | ||
.map(|entry| entry.value().clone()) | ||
.collect(); | ||
let color = presets | ||
.color | ||
.iter() | ||
.map(|entry| entry.value().clone()) | ||
.collect(); | ||
let position = presets | ||
.position | ||
.iter() | ||
.map(|entry| entry.value().clone()) | ||
.collect(); | ||
|
||
Self { | ||
intensity, | ||
shutter, | ||
color, | ||
position, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ mod engine; | |
mod instance; | ||
mod module; | ||
mod processor; | ||
mod project_loading; | ||
mod spline; | ||
|
||
#[cfg(test)] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
crates/components/sequencer/src/effects/project_loading.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use mizer_module::*; | ||
use crate::{Effect, EffectEngine}; | ||
|
||
impl ProjectHandler for EffectEngine { | ||
fn get_name(&self) -> &'static str { | ||
"effects" | ||
} | ||
|
||
fn new_project(&mut self, _context: &mut impl ProjectHandlerContext) -> anyhow::Result<()> { | ||
self.clear(); | ||
self.load_defaults(); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn load_project(&mut self, context: &mut impl LoadProjectContext) -> anyhow::Result<()> { | ||
self.clear(); | ||
let effects = context.read_file::<Vec<Effect>>("effects")?; | ||
profiling::scope!("EffectEngine::load_project"); | ||
tracing::debug!("load effect engine"); | ||
for effect in &effects { | ||
self.effects.insert(effect.id, effect.clone()); | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
fn save_project(&self, context: &mut impl SaveProjectContext) -> anyhow::Result<()> { | ||
profiling::scope!("EffectEngine::save_project"); | ||
tracing::debug!("save effect engine"); | ||
let mut effects = Vec::with_capacity(self.effects.len()); | ||
for effect in self.effects.iter() { | ||
effects.push(effect.value().clone()); | ||
} | ||
|
||
context.write_file("effects", &effects)?; | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ mod sequencer; | |
mod state; | ||
mod value; | ||
mod cue_preset; | ||
mod project_loading; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use mizer_module::*; | ||
use crate::{Sequence, Sequencer}; | ||
|
||
impl ProjectHandler for Sequencer { | ||
fn get_name(&self) -> &'static str { | ||
"sequencer" | ||
} | ||
|
||
fn new_project(&mut self, context: &mut impl ProjectHandlerContext) -> anyhow::Result<()> { | ||
Check warning on line 9 in crates/components/sequencer/src/project_loading.rs GitHub Actions / clippyunused variable: `context`
|
||
self.clear(); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn load_project(&mut self, context: &mut impl LoadProjectContext) -> anyhow::Result<()> { | ||
let sequences = context.read_file::<Vec<Sequence>>("sequences")?; | ||
self.load_sequences(sequences); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn save_project(&self, context: &mut impl SaveProjectContext) -> anyhow::Result<()> { | ||
context.write_file("sequences", self.sequences())?; | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ pub mod commands; | |
mod models; | ||
mod module; | ||
mod registry; | ||
mod project_loading; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use mizer_module::{LoadProjectContext, ProjectHandler, ProjectHandlerContext, SaveProjectContext}; | ||
use crate::{Surface, SurfaceRegistry}; | ||
|
||
pub struct SurfaceProjectHandler; | ||
|
||
impl ProjectHandler for SurfaceProjectHandler { | ||
fn get_name(&self) -> &'static str { | ||
"surfaces" | ||
} | ||
|
||
fn new_project(&mut self, context: &mut impl ProjectHandlerContext) -> anyhow::Result<()> { | ||
let Some(registry) = context.try_get_mut::<SurfaceRegistry>() else { | ||
context.report_issue("Unable to load surfaces"); | ||
|
||
return Ok(()); | ||
}; | ||
registry.clear_surfaces(); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn load_project(&mut self, context: &mut impl LoadProjectContext) -> anyhow::Result<()> { | ||
let surfaces = context.read_file::<Vec<Surface>>("surfaces")?; | ||
let Some(registry) = context.try_get_mut::<SurfaceRegistry>() else { | ||
context.report_issue("Unable to load surfaces"); | ||
|
||
return Ok(()); | ||
}; | ||
registry.clear_surfaces(); | ||
registry.add_surfaces(surfaces); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn save_project(&self, context: &mut impl SaveProjectContext) -> anyhow::Result<()> { | ||
let Some(registry) = context.try_get_mut::<SurfaceRegistry>() else { | ||
context.report_issue("Unable to load surfaces"); | ||
|
||
return Ok(()); | ||
}; | ||
context.write_file("surfaces", registry.list_surfaces())?; | ||
Check failure on line 41 in crates/components/surfaces/src/project_loading.rs GitHub Actions / clippycannot borrow `*context` as mutable more than once at a time
|
||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ mod flags; | |
mod mizer; | ||
mod module_context; | ||
mod runtime_builder; | ||
mod project_handler; |
Oops, something went wrong.