You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
855B

  1. #include "rack.hpp"
  2. using namespace rack;
  3. extern Plugin *plugin;
  4. namespace bogaudio {
  5. struct TriggerOnLoadModule : Module {
  6. bool _triggerOnLoad = true;
  7. bool _shouldTriggerOnLoad = true;
  8. TriggerOnLoadModule(int numParams, int numInputs, int numOutputs, int numLights)
  9. : Module(numParams, numInputs, numOutputs, numLights)
  10. {
  11. }
  12. json_t* toJson() override;
  13. void fromJson(json_t* root) override;
  14. virtual bool shouldTriggerOnNextLoad() = 0;
  15. };
  16. struct TriggerOnLoadMenuItem : MenuItem {
  17. TriggerOnLoadModule* _module;
  18. TriggerOnLoadMenuItem(TriggerOnLoadModule* module, const char* label)
  19. : _module(module)
  20. {
  21. this->text = label;
  22. }
  23. void onAction(EventAction &e) override {
  24. _module->_triggerOnLoad = !_module->_triggerOnLoad;
  25. }
  26. void step() override {
  27. rightText = _module->_triggerOnLoad ? "✔" : "";
  28. }
  29. };
  30. } // namespace bogaudio