OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
style.cpp
Go to the documentation of this file.
1#include "mixer.h"
2#include "style.h"
3
4#include <stdexcept>
5#include <Tempest/Log>
6
7using namespace Tempest;
8using namespace Dx8;
9
11 input.read([this](Riff& c){
12 if(c.is("prth"))
13 c.read(&header,sizeof(header));
14 else if(c.is("note"))
15 c.readAll(notes);
16 else if(c.is("crve"))
17 c.readAll(curves);
18 });
19 }
20
22 if(!input.is("RIFF"))
23 throw std::runtime_error("not a riff");
24 input.readListId("DMST");
25 input.read([this](Riff& c){
26 implRead(c);
27 });
28 }
29
30void Style::implRead(Riff &input) {
31 if(input.is("RIFF")){
32 if(input.isListId("DMBD"))
33 band.emplace_back(input);
34 }
35 else if(input.is("guid")){
36 input.read(&guid,sizeof(guid));
37 }
38 else if(input.is("styh")){
39 input.read(&styh,sizeof(styh));
40 }
41 else if(input.is("LIST")){
42 if(input.isListId("pttn"))
43 patterns.emplace_back(input);
44 else if(input.isListId("part"))
45 parts.emplace_back(Part(input));
46 }
47 }
48
49const Style::Part* Style::findPart(const GUID &guid) const {
50 for(auto& i:parts)
51 if(i.header.guidPartID==guid)
52 return &i;
53 return nullptr;
54 }
bool is(const char *idx) const
Definition riff.h:19
void read(std::u16string &str)
Definition riff.cpp:29
void readAll(std::vector< T > &all)
Definition riff.h:44
void readListId()
Definition riff.cpp:13
bool isListId(const char *id)
Definition riff.cpp:24
DMUS_IO_STYLE styh
Definition style.h:28
std::vector< Part > parts
Definition style.h:30
std::vector< Pattern > patterns
Definition style.h:31
Style(Riff &riff)
Definition style.cpp:21
std::vector< Band > band
Definition style.h:29
GUID guid
Definition style.h:27
const Part * findPart(const GUID &guid) const
Definition style.cpp:49
Definition band.h:10
std::vector< DMUS_IO_STYLECURVE > curves
Definition style.h:24
Part(Riff &riff)
Definition style.cpp:10
DMUS_IO_STYLEPART header
Definition style.h:22
std::vector< DMUS_IO_STYLENOTE > notes
Definition style.h:23