stoermelder / vcvrack-packone

Modules for VCV Rack
GNU General Public License v3.0
173 stars 38 forks source link

Glue labels not saved in selections #326

Closed mysterybear closed 1 year ago

mysterybear commented 1 year ago

Hey,

Is it just me or are glue labels not saved as part of saved selections?

mysterybear commented 1 year ago

Ah, also mappings from CV-MAP are not saved

mysterybear commented 1 year ago

Ah if I use STRIP everything's fine... I guess that's the suggested solution?

stoermelder commented 1 year ago

The selection-function is integrated in Rack, unfortunately there is no support for mappings or custom elements (like labels). I suggest a feature request on Rack's development.

stoermelder commented 1 year ago

Feature request submited to the VCV-support.

I like to propose a feature for Rack v2: Currently mappings within CV-Map are lost when loaded or cloned using the selection feature. The problem is obviously, that added modules included in the selection get new module-ids which can't be addressed from the preset loaded into CV-Map. CV-Map must get knowledge which "old" ids map to "new" ids and update the preset accordingly while loading. Some other modules could be benefit from this feature, like my labeling module "GLUE": vcvrack-packone/Glue.md at v2-dev · stoermelder/vcvrack-packone (github.com)

vcvrack-packone/Glue.md at v2-dev · stoermelder/vcvrack-packone Modules for VCV Rack . Contribute to stoermelder/vcvrack-packone development by creating an account on GitHub. github.com

The routine for pasting a selection had to look this way then:

  • Add modules from the selection to Rack and create a map for old ids to new ids
  • Load the presets of the modules from the selection, supplied with the map
  • Do rest of the stuff, like cables

Following this, the signature of void Module::dataFromJson(json_t*) should be changed to something like Module::dataFromJson(const LoadParams&) with

   struct LoadParaParams {
     json_t* data;
     std::map<int64_t, int64_t> newModuleIds;
   };

I am aware that this would be an ABI breaking change, so maybe it can be implemented as an "extension" class until the next major update of Rack. Something like this:

struct ModuleLoadEx {
   struct LoadParams {
       json_t* rootJ;
       std::map<int64_t, int64_t> newModuleIds;  
    };
    virtual void dataFromJson(const LoadParams& params) {
       Module* m = dynamic_cast<Module*>(this);
       if (m) {
      m->dataFromJson(params.rootJ);
       }
    }
};

Which can be used this way:

struct MyModule : Module, ModuleLoadEx {
   void dataFromJson(const LoadParams& params) override {
      // do stuff here
   }
};

Later on (Rack v3, vor example) this could be set to the default behavior without breaking the current API. Thanks for your consideration, Ben

stoermelder commented 1 year ago

VCV support responded they would not add something for this scenario at the moment, so I close this for now.

stoermelder commented 1 year ago

Just to let you know: I added module S++ which adds options to paste or import Rack selections while preserving GLUE's labels. 146d3d366a5e91ec5c4518e486d7c54b05175990