#ifndef __AMUSE_AUDIOGROUPFILEPRESENTER_HPP__ #define __AMUSE_AUDIOGROUPFILEPRESENTER_HPP__ #include #include #include "optional.hpp" #include #include #define WIN32_LEAN_AND_MEAN #include #include namespace amuse { class VSTBackend; class VSTEditor; class AudioGroupFilePresenter; struct AudioGroupDataCollection { std::wstring m_path; std::wstring m_name; std::vector m_projData; std::vector m_poolData; std::vector m_sdirData; std::vector m_sampData; struct MetaData { amuse::DataFormat fmt; uint32_t absOffs; uint32_t active; MetaData(amuse::DataFormat fmtIn, uint32_t absOffsIn, uint32_t activeIn) : fmt(fmtIn), absOffs(absOffsIn), active(activeIn) {} MetaData(athena::io::FileReader& r) : fmt(amuse::DataFormat(r.readUint32Little())), absOffs(r.readUint32Little()), active(r.readUint32Little()) {} }; std::experimental::optional m_metaData; std::experimental::optional m_loadedData; const amuse::AudioGroup* m_loadedGroup; struct GroupToken { int m_groupId; const amuse::SongGroupIndex* m_song = nullptr; const amuse::SFXGroupIndex* m_sfx = nullptr; GroupToken(int id, const amuse::SongGroupIndex* song) : m_groupId(id), m_song(song) {} GroupToken(int id, const amuse::SFXGroupIndex* sfx) : m_groupId(id), m_sfx(sfx) {} }; std::vector m_groupTokens; bool loadProj(); bool loadPool(); bool loadSdir(); bool loadSamp(); bool loadMeta(); AudioGroupDataCollection(const std::wstring& path, const std::wstring& name); bool isDataComplete() const {return m_projData.size() && m_poolData.size() && m_sdirData.size() && m_sampData.size() && m_metaData;} bool _attemptLoad(); bool _indexData(); void addToEngine(amuse::Engine& engine); void removeFromEngine(amuse::Engine& engine) const; }; struct AudioGroupCollection { using GroupIterator = std::map>::iterator; std::wstring m_path; std::wstring m_name; std::map> m_groups; std::vector m_iteratorVec; AudioGroupCollection(const std::wstring& path, const std::wstring& name); void addCollection(std::vector>&& collection); void update(AudioGroupFilePresenter& presenter); void populateFiles(VSTEditor& editor, HTREEITEM colHandle, size_t parentIdx); }; class AudioGroupFilePresenter { friend class VSTBackend; public: using CollectionIterator = std::map>::iterator; private: VSTBackend& m_backend; std::map> m_audioGroupCollections; std::vector m_iteratorVec; public: AudioGroupFilePresenter(VSTBackend& backend) : m_backend(backend) {} void update(); void populateCollectionColumn(VSTEditor& editor); void populateGroupColumn(VSTEditor& editor, int collectionIdx, int fileIdx); void populatePageColumn(VSTEditor& editor, int collectionIdx, int fileIdx, int groupIdx); void addCollection(const std::wstring& name, std::vector>&& collection); void removeCollection(unsigned idx); VSTBackend& getBackend() {return m_backend;} }; } #endif // __AMUSE_AUDIOGROUPFILEPRESENTER_HPP__