Skip to content

Commit

Permalink
Include the documentation in the libarry (#35)
Browse files Browse the repository at this point in the history
so not everyone has to roll their own
adjust the juce module
leave the rack module as is
  • Loading branch information
baconpaul authored Apr 25, 2024
1 parent 4a0355a commit 2f613de
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@ 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

${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
Expand Down Expand Up @@ -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)
Expand Down
28 changes: 5 additions & 23 deletions src-juce/AWConsolidatedEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
23 changes: 23 additions & 0 deletions src/AirwinRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,35 @@

#include "AirwinRegistry.h"

#include <cmrc/cmrc.hpp>

CMRC_DECLARE(awdoc_resources);

std::vector<AirwinRegistry::awReg> AirwinRegistry::registry;
std::set<std::string> AirwinRegistry::categories;
std::vector<int> AirwinRegistry::fxAlphaOrdering;
std::map<std::string, std::set<std::string>> AirwinRegistry::fxByCategory;
std::unordered_map<std::string, int> 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()
{
Expand Down
2 changes: 2 additions & 0 deletions src/AirwinRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ struct AirwinRegistry
return neighborIndexFor(nameToIndex[s], dir);
}

static std::string documentationStringFor(int index);

static void dumpStatsToStdout();
};
#endif // AIRWIN2RACK_AIRWINREGISTRY_H

0 comments on commit 2f613de

Please sign in to comment.