ソースを参照

parity129: mix lock in the preset menu (keep the Mix when loading presets)

Ka1-S 1 ヶ月 前
親
コミット
8b5256269d
3 ファイル変更、33 行追加、3 行削除
  1. 1 0
      resources/i18n/pt-BR.txt
  2. 4 1
      src/ui/I18nData.h
  3. 28 2
      src/ui/PluginHeader.cpp

+ 1 - 0
resources/i18n/pt-BR.txt

@@ -2848,3 +2848,4 @@ countries: br
 "Phase R" = "Fase D"
 "Early|Late" = "Iniciais|Cauda"
 "Tap tempo: click in time (two taps or more) to set the delay" = "Tap tempo: clique no tempo (dois toques ou mais) para definir o delay"
+"Keep the Mix when loading presets" = "Manter o Mix ao carregar presets"

+ 4 - 1
src/ui/I18nData.h

@@ -7519,6 +7519,9 @@ inline constexpr unsigned char ptBR[] = {
 32, 34, 84, 97, 112, 32, 116, 101, 109, 112, 111, 58, 32, 99, 108, 105, 113, 117, 101, 32, 110, 111, 32, 116,
 101, 109, 112, 111, 32, 40, 100, 111, 105, 115, 32, 116, 111, 113, 117, 101, 115, 32, 111, 117, 32, 109, 97, 105,
 115, 41, 32, 112, 97, 114, 97, 32, 100, 101, 102, 105, 110, 105, 114, 32, 111, 32, 100, 101, 108, 97, 121, 34,
-10,
+10, 34, 75, 101, 101, 112, 32, 116, 104, 101, 32, 77, 105, 120, 32, 119, 104, 101, 110, 32, 108, 111, 97, 100,
+105, 110, 103, 32, 112, 114, 101, 115, 101, 116, 115, 34, 32, 61, 32, 34, 77, 97, 110, 116, 101, 114, 32, 111,
+32, 77, 105, 120, 32, 97, 111, 32, 99, 97, 114, 114, 101, 103, 97, 114, 32, 112, 114, 101, 115, 101, 116, 115,
+34, 10,
 };
 } // namespace lynx::i18n::data

+ 28 - 2
src/ui/PluginHeader.cpp

@@ -83,6 +83,29 @@ bool isLynxEngine (EffectKind kind)
 {
     return flPluginsForEffect (kind).empty();
 }
+
+// "Keep the Mix when loading presets" (the reference reverbs' mix lock): per engine, a marker file in its presets folder
+juce::File mixLockFile (EffectKind kind) { return userFolder (kind).getChildFile (".mixlock"); }
+bool mixLocked (EffectKind kind) { return mixLockFile (kind).existsAsFile(); }
+void setMixLocked (EffectKind kind, bool on)
+{
+    if (on)
+    {
+        userFolder (kind).createDirectory();
+        mixLockFile (kind).create();
+    }
+    else
+        mixLockFile (kind).deleteFile();
+}
+
+// the preset's parameters with the slot's Mix kept when the mix lock is on
+EffectParams withMixLock (EffectKind kind, EffectParams params, const EffectParams& current)
+{
+    if (mixLocked (kind))
+        if (const auto p = presets::paramByName (kind, "Mix"); p >= 0)
+            params[(std::size_t) p] = current[(std::size_t) p];
+    return params;
+}
 } // namespace
 
 juce::File userFolder (EffectKind kind)
@@ -357,7 +380,8 @@ void PresetBar::loadFactory (int index)
         return;
     gesture = true;
     willEdit();
-    restore (presets::apply (kind, list[(std::size_t) index], engine.getSong().bpm, nullptr, &fx->params), fx->state, list[(std::size_t) index].name);
+    restore (withMixLock (kind, presets::apply (kind, list[(std::size_t) index], engine.getSong().bpm, nullptr, &fx->params), fx->params), fx->state,
+             list[(std::size_t) index].name);
     gesture = true;
 }
 
@@ -371,7 +395,7 @@ void PresetBar::loadUser (const juce::File& file)
         return;
     gesture = true;
     willEdit();
-    restore (loaded->params, fx->state, loaded->name.empty() ? file.getFileNameWithoutExtension().toStdString() : loaded->name);
+    restore (withMixLock (kind, loaded->params, fx->params), fx->state, loaded->name.empty() ? file.getFileNameWithoutExtension().toStdString() : loaded->name);
     gesture = true;
 }
 
@@ -468,6 +492,8 @@ void PresetBar::showPresetMenu (juce::Component& owner, const FlPresets* flPrese
             });
             break;
         }
+    if (presets::paramByName (kind, "Mix") >= 0)
+        menu.addItem (tr ("Keep the Mix when loading presets"), true, mixLocked (kind), [this] { setMixLocked (kind, ! mixLocked (kind)); });
     menu.addItem (tr ("Show the presets folder"), [this] {
         const auto folder = userFolder (kind);
         folder.createDirectory();