amuse/AudioUnit/AudioGroupFilePresenter.hpp

170 lines
5.3 KiB
C++
Raw Normal View History

#ifndef __AMUSE_AUDIOUNIT_AUDIOGROUPFILEPRESENTER_HPP__
#define __AMUSE_AUDIOUNIT_AUDIOGROUPFILEPRESENTER_HPP__
#import <Foundation/Foundation.h>
2016-06-03 02:53:52 +00:00
#import <AppKit/AppKit.h>
#include <map>
#include <string>
2016-06-04 02:34:35 +00:00
#include "optional.hpp"
#include <amuse/amuse.hpp>
#include <athena/FileReader.hpp>
@class AudioGroupFilePresenter;
2016-06-04 02:34:35 +00:00
@class AudioGroupDataToken;
@class AudioGroupCollectionToken;
2016-06-05 22:37:49 +00:00
@class AudioGroupSFXToken;
@class AudioGroupSampleToken;
2016-06-07 03:42:51 +00:00
@class AudioGroupToken;
@protocol AudioGroupClient
- (amuse::Engine&)getAmuseEngine;
@end
struct AudioGroupDataCollection
{
2016-06-04 02:34:35 +00:00
std::string m_name;
2016-06-03 02:53:52 +00:00
NSURL* m_proj;
NSURL* m_pool;
NSURL* m_sdir;
NSURL* m_samp;
2016-06-04 02:34:35 +00:00
NSURL* m_meta;
AudioGroupDataToken* m_token;
2016-07-14 04:54:46 +00:00
2016-06-04 02:34:35 +00:00
std::vector<uint8_t> m_projData;
std::vector<uint8_t> m_poolData;
std::vector<uint8_t> m_sdirData;
std::vector<uint8_t> m_sampData;
2016-07-14 04:54:46 +00:00
2016-06-04 02:34:35 +00:00
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-04 02:34:35 +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-04 02:34:35 +00:00
};
std::experimental::optional<MetaData> m_metaData;
2016-07-14 04:54:46 +00:00
2016-06-04 02:34:35 +00:00
std::experimental::optional<amuse::AudioGroupData> m_loadedData;
2016-06-05 22:37:49 +00:00
const amuse::AudioGroup* m_loadedGroup;
2016-06-07 03:42:51 +00:00
std::vector<AudioGroupToken*> m_groupTokens;
void moveURL(NSURL* oldUrl, NSURL* newUrl);
2016-06-03 02:53:52 +00:00
bool loadProj(AudioGroupFilePresenter* presenter);
bool loadPool(AudioGroupFilePresenter* presenter);
bool loadSdir(AudioGroupFilePresenter* presenter);
bool loadSamp(AudioGroupFilePresenter* presenter);
2016-06-04 02:34:35 +00:00
bool loadMeta(AudioGroupFilePresenter* presenter);
2016-06-04 02:34:35 +00:00
AudioGroupDataCollection(const std::string& name, NSURL* proj, NSURL* pool, NSURL* sdir, NSURL* samp, NSURL* meta);
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-04 02:34:35 +00:00
bool _attemptLoad(AudioGroupFilePresenter* presenter);
2016-06-07 03:42:51 +00:00
bool _indexData(AudioGroupFilePresenter* presenter);
2016-06-04 22:38:55 +00:00
void enable(AudioGroupFilePresenter* presenter);
void disable(AudioGroupFilePresenter* presenter);
2016-06-04 02:34:35 +00:00
};
struct AudioGroupCollection
{
NSURL* m_url;
2016-07-14 04:54:46 +00:00
2016-06-04 02:34:35 +00:00
AudioGroupCollectionToken* m_token;
2016-06-04 22:38:55 +00:00
std::map<std::string, std::unique_ptr<AudioGroupDataCollection>> m_groups;
std::vector<std::map<std::string, std::unique_ptr<AudioGroupDataCollection>>::iterator> m_filterGroups;
2016-07-14 04:54:46 +00:00
2016-06-04 02:34:35 +00:00
AudioGroupCollection(NSURL* url);
2016-06-07 03:42:51 +00:00
void addCollection(AudioGroupFilePresenter* presenter,
std::vector<std::pair<std::string, amuse::IntrusiveAudioGroupData>>&& collection);
2016-06-04 02:34:35 +00:00
void update(AudioGroupFilePresenter* presenter);
2016-06-04 22:38:55 +00:00
bool doSearch(const std::string& str);
2016-06-07 03:42:51 +00:00
bool doActiveFilter();
2016-06-05 22:37:49 +00:00
void addSFX(std::vector<AudioGroupSFXToken*>& vecOut);
void addSamples(std::vector<AudioGroupSampleToken*>& vecOut);
};
2016-06-04 02:34:35 +00:00
@interface AudioGroupDataToken : NSObject
{
@public
AudioGroupDataCollection* m_collection;
}
- (id)initWithDataCollection:(AudioGroupDataCollection*)collection;
@end
@interface AudioGroupCollectionToken : NSObject
{
@public
AudioGroupCollection* m_collection;
}
- (id)initWithCollection:(AudioGroupCollection*)collection;
@end
2016-06-05 22:37:49 +00:00
@interface AudioGroupSFXToken : NSObject
{
@public
NSAttributedString* m_name;
int m_loadId;
const amuse::SFXGroupIndex::SFXEntry* m_sfx;
}
- (id)initWithName:(NSAttributedString*)name loadId:(int)loadId sfx:(const amuse::SFXGroupIndex::SFXEntry*)sfx;
@end
@interface AudioGroupSampleToken : NSObject
{
@public
NSAttributedString* m_name;
const std::pair<amuse::AudioGroupSampleDirectory::Entry, amuse::AudioGroupSampleDirectory::ADPCMParms>* m_sample;
}
2016-07-14 04:54:46 +00:00
- (id)
initWithName:(NSAttributedString*)name
samp:(const std::pair<amuse::AudioGroupSampleDirectory::Entry, amuse::AudioGroupSampleDirectory::ADPCMParms>*)
sample;
2016-06-05 22:37:49 +00:00
@end
2016-06-07 03:42:51 +00:00
@interface AudioGroupToken : NSObject
{
@public
NSString* m_name;
2016-06-08 04:33:15 +00:00
int m_id;
2016-06-07 03:42:51 +00:00
const amuse::SongGroupIndex* m_song;
const amuse::SFXGroupIndex* m_sfx;
}
2016-06-08 04:33:15 +00:00
- (id)initWithName:(NSString*)name id:(int)gid songGroup:(const amuse::SongGroupIndex*)group;
- (id)initWithName:(NSString*)name id:(int)gid sfxGroup:(const amuse::SFXGroupIndex*)group;
2016-06-07 03:42:51 +00:00
@end
2016-06-04 02:34:35 +00:00
@interface AudioGroupFilePresenter : NSObject <NSFilePresenter, NSOutlineViewDataSource, NSOutlineViewDelegate>
{
2016-06-07 03:42:51 +00:00
@public
id<AudioGroupClient> m_audioGroupClient;
NSURL* m_groupURL;
2016-06-04 22:38:55 +00:00
std::map<std::string, std::unique_ptr<AudioGroupCollection>> m_audioGroupCollections;
std::vector<std::map<std::string, std::unique_ptr<AudioGroupCollection>>::iterator> m_filterAudioGroupCollections;
2016-06-07 03:42:51 +00:00
NSOutlineView* m_lastOutlineView;
NSString* m_searchStr;
2016-07-14 04:54:46 +00:00
2016-06-05 22:37:49 +00:00
std::vector<AudioGroupSFXToken*> m_sfxTableData;
std::vector<AudioGroupSampleToken*> m_sampleTableData;
}
2016-06-07 03:42:51 +00:00
- (id)initWithAudioGroupClient:(id<AudioGroupClient>)client;
2016-07-14 04:54:46 +00:00
- (BOOL)addCollectionName:(std::string&&)name
items:(std::vector<std::pair<std::string, amuse::IntrusiveAudioGroupData>>&&)collection;
2016-06-03 02:53:52 +00:00
- (void)update;
2016-06-04 02:34:35 +00:00
- (void)resetIterators;
2016-06-04 22:38:55 +00:00
- (void)setSearchFilter:(NSString*)str;
- (void)removeSelectedItem;
@end
#endif // __AMUSE_AUDIOUNIT_AUDIOGROUPFILEPRESENTER_HPP__