Skip to content

Commit

Permalink
Complain when attempting to add Playtime matrix to Helgobox instance …
Browse files Browse the repository at this point in the history
…if REAPER version too old
  • Loading branch information
helgoboss committed Dec 7, 2024
1 parent dd65b96 commit 135010b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
14 changes: 13 additions & 1 deletion main/src/domain/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ impl Instance {
#[cfg(feature = "playtime")]
mod playtime_impl {
use crate::domain::instance::NO_CLIP_MATRIX_SET;
use crate::domain::{Instance, QualifiedClipMatrixEvent};
use crate::domain::{
err_if_reaper_version_too_low_for_playtime, Instance, QualifiedClipMatrixEvent,
};
use anyhow::Context;
use base::NamedChannelSender;
use reaper_high::OrCurrentProject;
Expand Down Expand Up @@ -346,6 +348,7 @@ mod playtime_impl {
if self.playtime.clip_matrix.is_some() {
return Ok(false);
}
err_if_reaper_version_too_low_for_playtime()?;
let track = self.processor_context.track()
.context("Sorry, Playtime is not intended to be used from the monitoring FX chain! If you have a really good use case for that, please write to [email protected] and we will see what we can do.")?;
let matrix =
Expand Down Expand Up @@ -475,3 +478,12 @@ pub enum PotStateChangedEvent {

#[cfg(feature = "playtime")]
const NO_CLIP_MATRIX_SET: &str = "no Playtime matrix set for this instance";

#[cfg(feature = "playtime")]
pub fn err_if_reaper_version_too_low_for_playtime() -> anyhow::Result<()> {
const MIN_REAPER_VERSION: &str = "7";
if reaper_high::Reaper::get().version().revision() < MIN_REAPER_VERSION {
anyhow::bail!("Please update REAPER to version {MIN_REAPER_VERSION} to access Playtime!");
}
Ok(())
}
10 changes: 3 additions & 7 deletions main/src/infrastructure/plugin/backbone_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2980,17 +2980,17 @@ pub struct NewInstanceOutcome {

#[cfg(feature = "playtime")]
mod playtime_impl {
use crate::domain::err_if_reaper_version_too_low_for_playtime;
use crate::infrastructure::data::LicenseManager;
use crate::infrastructure::plugin::{BackboneShell, NewInstanceOutcome};
use anyhow::{bail, Context};
use anyhow::Context;
use base::metrics_util::{record_duration, record_occurrence};
use camino::Utf8PathBuf;
use playtime_api::persistence::PlaytimeSettings;
use playtime_clip_engine::PlaytimeEngine;
use reaper_high::{GroupingBehavior, Project, Reaper};
use reaper_medium::{GangBehavior, InputMonitoringMode, RecordingInput};
use std::fs;
use crate::infrastructure::plugin::backbone_shell::MIN_REAPER_VERSION_FOR_PLAYTIME;

impl BackboneShell {
pub(crate) fn read_playtime_settings() -> Option<PlaytimeSettings> {
Expand All @@ -3008,9 +3008,7 @@ mod playtime_impl {
}

async fn add_and_show_playtime() -> anyhow::Result<()> {
if Reaper::get().version().revision() < MIN_REAPER_VERSION_FOR_PLAYTIME {
bail!("Please update REAPER to version 7 to access Playtime!");
}
err_if_reaper_version_too_low_for_playtime()?;
let project = Reaper::get().current_project();
create_new_instance_in_project(project, "Playtime").await?;
enable_playtime_for_first_helgobox_instance_and_show_it()?;
Expand Down Expand Up @@ -3167,5 +3165,3 @@ struct MatchingSourceOutcome {
mapping: SharedMapping,
source_is_learnable: bool,
}

const MIN_REAPER_VERSION_FOR_PLAYTIME: &str = "7";

0 comments on commit 135010b

Please sign in to comment.