From 2d5b3a01bb913f47414ddf65a354953eff4d8096 Mon Sep 17 00:00:00 2001 From: hemmer <915048+hemmer@users.noreply.github.com> Date: Tue, 19 Apr 2022 15:34:20 +0100 Subject: [PATCH 1/2] Fix Elements Ominous Voice bug https://github.com/VCVRack/AudibleInstruments/issues/116 --- src/Elements.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Elements.cpp b/src/Elements.cpp index 661d6be..6615548 100644 --- a/src/Elements.cpp +++ b/src/Elements.cpp @@ -397,16 +397,17 @@ struct ElementsWidget : ModuleWidget { menu->addChild(createMenuLabel("Models")); - static const std::vector modelLabels = { - "Original", - "Non-linear string", - "Chords", - "Ominous voice", + static const std::vector> modelLabels = { + std::make_pair("Original", 0), + std::make_pair("Non-linear string", 1), + std::make_pair("Chords", 2), + std::make_pair("Ominous voice", -1), }; - for (int i = 0; i < 4; i++) { - menu->addChild(createCheckMenuItem(modelLabels[i], "", - [=]() {return module->getModel() == i;}, - [=]() {module->setModel(i);} + + for (auto modelLabel : modelLabels) { + menu->addChild(createCheckMenuItem(modelLabel.first, "", + [=]() {return module->getModel() == modelLabel.second;}, + [=]() {module->setModel(modelLabel.second);} )); } } From 6f8c728e2aa765742faa4d12c1d8d4b54c83d2c8 Mon Sep 17 00:00:00 2001 From: hemmer <915048+hemmer@users.noreply.github.com> Date: Tue, 19 Apr 2022 19:13:07 +0100 Subject: [PATCH 2/2] Avoid ambiguously typed syntax --- src/Elements.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Elements.cpp b/src/Elements.cpp index 6615548..77e3d74 100644 --- a/src/Elements.cpp +++ b/src/Elements.cpp @@ -397,17 +397,22 @@ struct ElementsWidget : ModuleWidget { menu->addChild(createMenuLabel("Models")); - static const std::vector> modelLabels = { - std::make_pair("Original", 0), - std::make_pair("Non-linear string", 1), - std::make_pair("Chords", 2), - std::make_pair("Ominous voice", -1), + struct ModeNameAndId { + std::string name; + int id; + }; + + static const std::vector modelLabels = { + {"Original", 0}, + {"Non-linear string", 1}, + {"Chords", 2}, + {"Ominous voice", -1} }; for (auto modelLabel : modelLabels) { - menu->addChild(createCheckMenuItem(modelLabel.first, "", - [=]() {return module->getModel() == modelLabel.second;}, - [=]() {module->setModel(modelLabel.second);} + menu->addChild(createCheckMenuItem(modelLabel.name, "", + [=]() {return module->getModel() == modelLabel.id;}, + [=]() {module->setModel(modelLabel.id);} )); } }