mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-30 10:03:56 +01:00
Layers: a generator swapped in place takes its new kind's name
This commit is contained in:
1 parent
ca4ea4bccf
commit
70509468e8
1 file changed
+7
-5
@@ -1122,6 +1122,13 @@ pub(crate) fn set(session: &mut Session, params: &Value) -> Result<Value> {
|
||||
session.edit("Edit effect", |session| {
|
||||
let edited = session.doc.project.effect_mut(effect).ok_or_else(|| bad(CMD, format!("no effect {}", effect.0)))?;
|
||||
if let Some(generator) = swapped_generator {
|
||||
// A name taken from the kind follows the new kind, unless one is given with the change
|
||||
if let EffectKind::Generator(old) = &edited.kind
|
||||
&& (edited.name == old.kind.label() || edited.name == FORMER_GENERATOR_NAME)
|
||||
{
|
||||
edited.name = generator.kind.label().to_string();
|
||||
}
|
||||
|
||||
edited.kind = EffectKind::Generator(generator);
|
||||
}
|
||||
if let Some((kind, label)) = swapped {
|
||||
@@ -1153,11 +1160,6 @@ pub(crate) fn set(session: &mut Session, params: &Value) -> Result<Value> {
|
||||
if let Some(kind) = generator_kind
|
||||
&& kind != generator.kind
|
||||
{
|
||||
// A name taken from the kind follows the new kind
|
||||
let named_by_kind = edited.name == generator.kind.label() || edited.name == FORMER_GENERATOR_NAME;
|
||||
if named_by_kind && name_param(params).is_none() {
|
||||
edited.name = kind.label().to_string();
|
||||
}
|
||||
generator.kind = kind;
|
||||
generator.detail = Generator::new(kind).detail;
|
||||
generator.inputs.retain(|map, _| kind.inputs().contains(map));
|
||||
|
||||
Reference in new issue
Block a user