diff --git a/CMakeLists.txt b/CMakeLists.txt index b604b33..b570534 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,13 @@ if(NOT MSVC) add_compile_options(-fvisibility=hidden -fvisibility-inlines-hidden) endif() + +file(GLOB AWDOC_RESOURCES_GLOB + res/awpdoc/*.txt +) +include(cmake/CmakeRC.cmake) +cmrc_add_resource_library(awdoc_resources ${AWDOC_RESOURCES_GLOB}) + add_library(airwin-registry STATIC src/AirwinRegistry.cpp src/airwin2rackbase.cpp @@ -32,6 +39,7 @@ add_library(airwin-registry STATIC ${AIRWIN_SOURCES}) target_compile_definitions(airwin-registry PRIVATE _USE_MATH_DEFINES) +target_link_libraries(airwin-registry awdoc_resources) if (NOT MSVC) # consistent even in warnings that chris is @@ -66,13 +74,10 @@ if (${BUILD_RACK_PLUGIN}) endif() if (${BUILD_JUCE_PLUGIN}) - file(GLOB AWCON_RESOURCES_GLOB res/*.ttf res/clipper.svg - res/awpdoc/*.txt ) - include(cmake/CmakeRC.cmake) cmrc_add_resource_library(awconsolidated_resources ${AWCON_RESOURCES_GLOB}) add_subdirectory(src-juce) diff --git a/src-juce/AWConsolidatedEditor.cpp b/src-juce/AWConsolidatedEditor.cpp index 1a0b9a5..bc32062 100644 --- a/src-juce/AWConsolidatedEditor.cpp +++ b/src-juce/AWConsolidatedEditor.cpp @@ -469,29 +469,11 @@ void AWConsolidatedAudioProcessorEditor::idle() { if (processor.refreshUI.exchange(false)) { - auto reg = AirwinRegistry::registry[processor.curentProcessorIndex]; - auto doc = std::string("res/awpdoc/") + reg.name + ".txt"; - - auto fs = awres::get_filesystem(); - try - { - if (fs.is_file(doc)) - { - auto fn = fs.open(doc); - docString = std::string(fn.begin(), fn.end()); - docHeader = docString.upToFirstOccurrenceOf("\n", false, false); - docString = docString.fromFirstOccurrenceOf("\n", false, false).trim(); - if (docArea) - docArea->rebuild(); - } - else - { - docString = "Documentation not present"; - } - } - catch (std::exception &e) - { - } + docString = AirwinRegistry::documentationStringFor(processor.curentProcessorIndex); + docHeader = docString.upToFirstOccurrenceOf("\n", false, false); + docString = docString.fromFirstOccurrenceOf("\n", false, false).trim(); + if (docArea) + docArea->rebuild(); repaint(); } diff --git a/src/AirwinRegistry.cpp b/src/AirwinRegistry.cpp index a16a7bf..585ca50 100644 --- a/src/AirwinRegistry.cpp +++ b/src/AirwinRegistry.cpp @@ -8,12 +8,35 @@ #include "AirwinRegistry.h" +#include + +CMRC_DECLARE(awdoc_resources); + std::vector AirwinRegistry::registry; std::set AirwinRegistry::categories; std::vector AirwinRegistry::fxAlphaOrdering; std::map> AirwinRegistry::fxByCategory; std::unordered_map AirwinRegistry::nameToIndex; +std::string AirwinRegistry::documentationStringFor(int index) +{ + auto nm = registry[index].name; + auto fs = cmrc::awdoc_resources::get_filesystem(); + auto doc = std::string("res/awpdoc/") + nm + ".txt"; + + try + { + if (fs.is_file(doc)) + { + auto fn = fs.open(doc); + return std::string(fn.begin(), fn.end()); + } + } + catch (std::exception &e) + { + } + return ""; +} void AirwinRegistry::dumpStatsToStdout() { diff --git a/src/AirwinRegistry.h b/src/AirwinRegistry.h index 74b9dec..c060843 100644 --- a/src/AirwinRegistry.h +++ b/src/AirwinRegistry.h @@ -103,6 +103,8 @@ struct AirwinRegistry return neighborIndexFor(nameToIndex[s], dir); } + static std::string documentationStringFor(int index); + static void dumpStatsToStdout(); }; #endif // AIRWIN2RACK_AIRWINREGISTRY_H