2016-06-12 04:52:40 +00:00
|
|
|
#ifndef __AMUSE_AUDIOGROUPFILEPRESENTER_HPP__
|
|
|
|
#define __AMUSE_AUDIOGROUPFILEPRESENTER_HPP__
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
#include "optional.hpp"
|
|
|
|
#include <amuse/amuse.hpp>
|
|
|
|
#include <athena/FileReader.hpp>
|
|
|
|
|
2016-06-13 05:47:07 +00:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#include <CommCtrl.h>
|
|
|
|
|
2016-06-12 04:52:40 +00:00
|
|
|
namespace amuse
|
|
|
|
{
|
|
|
|
class VSTBackend;
|
|
|
|
class VSTEditor;
|
|
|
|
class AudioGroupFilePresenter;
|
|
|
|
|
|
|
|
struct AudioGroupDataCollection
|
|
|
|
{
|
|
|
|
std::wstring m_path;
|
|
|
|
std::wstring m_name;
|
|
|
|
|
|
|
|
std::vector<uint8_t> m_projData;
|
|
|
|
std::vector<uint8_t> m_poolData;
|
|
|
|
std::vector<uint8_t> m_sdirData;
|
|
|
|
std::vector<uint8_t> m_sampData;
|
|
|
|
|
|
|
|
struct MetaData
|
|
|
|
{
|
|
|
|
amuse::DataFormat fmt;
|
|
|
|
uint32_t absOffs;
|
|
|
|
uint32_t active;
|
|
|
|
MetaData(amuse::DataFormat fmtIn, uint32_t absOffsIn, uint32_t activeIn)
|
2016-07-14 04:54:46 +00:00
|
|
|
: fmt(fmtIn), absOffs(absOffsIn), active(activeIn)
|
|
|
|
{
|
|
|
|
}
|
2016-06-12 04:52:40 +00:00
|
|
|
MetaData(athena::io::FileReader& r)
|
2016-07-14 04:54:46 +00:00
|
|
|
: fmt(amuse::DataFormat(r.readUint32Little())), absOffs(r.readUint32Little()), active(r.readUint32Little())
|
|
|
|
{
|
|
|
|
}
|
2016-06-12 04:52:40 +00:00
|
|
|
};
|
|
|
|
std::experimental::optional<MetaData> m_metaData;
|
|
|
|
|
|
|
|
std::experimental::optional<amuse::AudioGroupData> 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<GroupToken> m_groupTokens;
|
|
|
|
|
|
|
|
bool loadProj();
|
|
|
|
bool loadPool();
|
|
|
|
bool loadSdir();
|
|
|
|
bool loadSamp();
|
|
|
|
bool loadMeta();
|
|
|
|
|
|
|
|
AudioGroupDataCollection(const std::wstring& path, const std::wstring& name);
|
2016-07-14 04:54:46 +00:00
|
|
|
bool isDataComplete() const
|
|
|
|
{
|
|
|
|
return m_projData.size() && m_poolData.size() && m_sdirData.size() && m_sampData.size() && m_metaData;
|
|
|
|
}
|
2016-06-14 01:54:24 +00:00
|
|
|
bool _attemptLoad();
|
|
|
|
bool _indexData();
|
|
|
|
|
|
|
|
void addToEngine(amuse::Engine& engine);
|
|
|
|
void removeFromEngine(amuse::Engine& engine) const;
|
2016-06-12 04:52:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct AudioGroupCollection
|
|
|
|
{
|
2016-06-14 01:54:24 +00:00
|
|
|
using GroupIterator = std::map<std::wstring, std::unique_ptr<AudioGroupDataCollection>>::iterator;
|
2016-06-12 04:52:40 +00:00
|
|
|
std::wstring m_path;
|
|
|
|
std::wstring m_name;
|
|
|
|
|
|
|
|
std::map<std::wstring, std::unique_ptr<AudioGroupDataCollection>> m_groups;
|
2016-06-14 01:54:24 +00:00
|
|
|
std::vector<GroupIterator> m_iteratorVec;
|
2016-06-12 04:52:40 +00:00
|
|
|
|
|
|
|
AudioGroupCollection(const std::wstring& path, const std::wstring& name);
|
2016-06-14 01:54:24 +00:00
|
|
|
void addCollection(std::vector<std::pair<std::wstring, amuse::IntrusiveAudioGroupData>>&& collection);
|
2016-06-12 04:52:40 +00:00
|
|
|
void update(AudioGroupFilePresenter& presenter);
|
2016-06-14 01:54:24 +00:00
|
|
|
void populateFiles(VSTEditor& editor, HTREEITEM colHandle, size_t parentIdx);
|
2016-06-12 04:52:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class AudioGroupFilePresenter
|
|
|
|
{
|
2016-06-14 01:54:24 +00:00
|
|
|
friend class VSTBackend;
|
2016-07-14 04:54:46 +00:00
|
|
|
|
2016-06-14 01:54:24 +00:00
|
|
|
public:
|
|
|
|
using CollectionIterator = std::map<std::wstring, std::unique_ptr<AudioGroupCollection>>::iterator;
|
2016-07-14 04:54:46 +00:00
|
|
|
|
2016-06-14 01:54:24 +00:00
|
|
|
private:
|
2016-06-12 04:52:40 +00:00
|
|
|
VSTBackend& m_backend;
|
|
|
|
std::map<std::wstring, std::unique_ptr<AudioGroupCollection>> m_audioGroupCollections;
|
2016-06-14 01:54:24 +00:00
|
|
|
std::vector<CollectionIterator> m_iteratorVec;
|
2016-07-14 04:54:46 +00:00
|
|
|
|
2016-06-12 04:52:40 +00:00
|
|
|
public:
|
|
|
|
AudioGroupFilePresenter(VSTBackend& backend) : m_backend(backend) {}
|
|
|
|
void update();
|
2016-06-14 01:54:24 +00:00
|
|
|
void populateCollectionColumn(VSTEditor& editor);
|
|
|
|
void populateGroupColumn(VSTEditor& editor, int collectionIdx, int fileIdx);
|
|
|
|
void populatePageColumn(VSTEditor& editor, int collectionIdx, int fileIdx, int groupIdx);
|
2016-06-12 04:52:40 +00:00
|
|
|
void addCollection(const std::wstring& name,
|
|
|
|
std::vector<std::pair<std::wstring, amuse::IntrusiveAudioGroupData>>&& collection);
|
2016-06-14 01:54:24 +00:00
|
|
|
void removeCollection(unsigned idx);
|
2016-07-14 04:54:46 +00:00
|
|
|
VSTBackend& getBackend() { return m_backend; }
|
2016-06-12 04:52:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __AMUSE_AUDIOGROUPFILEPRESENTER_HPP__
|